terraform: module computed vars with splat vars don't error

This commit is contained in:
Mitchell Hashimoto 2015-06-24 21:23:37 -07:00
parent 38efe4cb80
commit 54b961630d
4 changed files with 38 additions and 0 deletions

View File

@ -1935,6 +1935,23 @@ func TestContext2Refresh_targetedCountIndex(t *testing.T) {
}
}
func TestContext2Refresh_moduleComputedVar(t *testing.T) {
p := testProvider("aws")
m := testModule(t, "refresh-module-computed-var")
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
})
// This was failing (see GH-2188) at some point, so this test just
// verifies that the failure goes away.
if _, err := ctx.Refresh(); err != nil {
t.Fatalf("err: %s", err)
}
}
func TestContext2Refresh_delete(t *testing.T) {
p := testProvider("aws")
m := testModule(t, "refresh-basic")

View File

@ -437,6 +437,14 @@ func (i *Interpolater) computeResourceMultiVariable(
}
if len(values) == 0 {
// If the operation is refresh, it isn't an error for a value to
// be unknown. Instead, we return that the value is computed so
// that the graph can continue to refresh other nodes. It doesn't
// matter because the config isn't interpolated anyways.
if i.Operation == walkRefresh {
return config.UnknownVariableValue, nil
}
return "", fmt.Errorf(
"Resource '%s' does not have attribute '%s' "+
"for variable '%s'",

View File

@ -0,0 +1,5 @@
variable "value" {}
output "value" {
value = "${var.value}"
}

View File

@ -0,0 +1,8 @@
module "child" {
source = "./child"
value = "${join(" ", aws_instance.test.*.id)}"
}
resource "aws_instance" "test" {
value = "yes"
}