Merge pull request #12837 from hashicorp/b-interpolate

terraform: unknown value for variables not set
This commit is contained in:
Mitchell Hashimoto 2017-03-17 15:44:25 -07:00 committed by GitHub
commit 2698194f64
4 changed files with 41 additions and 1 deletions

View File

@ -60,6 +60,32 @@ func TestContext2Refresh(t *testing.T) {
}
}
func TestContext2Refresh_dataComputedModuleVar(t *testing.T) {
p := testProvider("aws")
m := testModule(t, "refresh-data-module-var")
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
p.RefreshFn = nil
p.RefreshReturn = &InstanceState{
ID: "foo",
}
s, err := ctx.Refresh()
if err != nil {
t.Fatalf("err: %s", err)
}
checkStateString(t, s, `
<no state>
module.child:
<no state>`)
}
func TestContext2Refresh_targeted(t *testing.T) {
p := testProvider("aws")
m := testModule(t, "refresh-targeted")

View File

@ -262,7 +262,7 @@ func (i *Interpolater) valueResourceVar(
// If it truly is missing, we'll catch it on a later walk.
// This applies only to graph nodes that interpolate during the
// config walk, e.g. providers.
if i.Operation == walkInput {
if i.Operation == walkInput || i.Operation == walkRefresh {
result[n] = unknownVariable()
return nil
}

View File

@ -0,0 +1,6 @@
variable "key" {}
data "aws_data_source" "foo" {
id = "${var.key}"
}

View File

@ -0,0 +1,8 @@
resource "aws_instance" "A" {
foo = "bar"
}
module "child" {
source = "child"
key = "${aws_instance.A.id}"
}