terraform: error if resource not found in module [GH-1997]

This commit is contained in:
Mitchell Hashimoto 2015-06-24 22:25:48 -07:00
parent 38efe4cb80
commit fcc710ca06
4 changed files with 25 additions and 1 deletions

View File

@ -6559,6 +6559,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) { func TestContext2Apply_vars(t *testing.T) {
m := testModule(t, "apply-vars") m := testModule(t, "apply-vars")
p := testProvider("aws") p := testProvider("aws")

View File

@ -362,7 +362,7 @@ MISSING:
// Validation for missing interpolations should happen at a higher // Validation for missing interpolations should happen at a higher
// semantic level. If we reached this point and don't have variables, // semantic level. If we reached this point and don't have variables,
// just return the computed value. // just return the computed value.
if scope == nil || scope.Resource == nil { if scope == nil && scope.Resource == nil {
return config.UnknownVariableValue, nil return config.UnknownVariableValue, nil
} }

View File

@ -0,0 +1 @@
variable "value" {}

View File

@ -0,0 +1,6 @@
resource "aws_instance" "foo" {}
module "child" {
source = "./child"
value = "${aws_instance.foo.nope}"
}