diff --git a/terraform/context_test.go b/terraform/context_test.go index e8ecb4573..55580cb9a 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -6615,6 +6615,23 @@ func TestContext2Apply_unknownAttribute(t *testing.T) { } } +func TestContext2Apply_unknownAttributeInterpolate(t *testing.T) { + m := testModule(t, "apply-unknown-interpolate") + p := testProvider("aws") + p.ApplyFn = testApplyFn + p.DiffFn = testDiffFn + ctx := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + }) + + if _, err := ctx.Plan(); err == nil { + t.Fatal("should error") + } +} + func TestContext2Apply_vars(t *testing.T) { m := testModule(t, "apply-vars") p := testProvider("aws") diff --git a/terraform/interpolate.go b/terraform/interpolate.go index c51000a37..a066c0a5f 100644 --- a/terraform/interpolate.go +++ b/terraform/interpolate.go @@ -362,7 +362,7 @@ MISSING: // Validation for missing interpolations should happen at a higher // semantic level. If we reached this point and don't have variables, // just return the computed value. - if scope == nil || scope.Resource == nil { + if scope == nil && scope.Resource == nil { return config.UnknownVariableValue, nil } diff --git a/terraform/test-fixtures/apply-unknown-interpolate/child/main.tf b/terraform/test-fixtures/apply-unknown-interpolate/child/main.tf new file mode 100644 index 000000000..6a2f85930 --- /dev/null +++ b/terraform/test-fixtures/apply-unknown-interpolate/child/main.tf @@ -0,0 +1 @@ +variable "value" {} diff --git a/terraform/test-fixtures/apply-unknown-interpolate/main.tf b/terraform/test-fixtures/apply-unknown-interpolate/main.tf new file mode 100644 index 000000000..1ee7dd6cb --- /dev/null +++ b/terraform/test-fixtures/apply-unknown-interpolate/main.tf @@ -0,0 +1,6 @@ +resource "aws_instance" "foo" {} + +module "child" { + source = "./child" + value = "${aws_instance.foo.nope}" +}