terraform: mapping overrides work

This commit is contained in:
Mitchell Hashimoto 2014-07-22 08:18:53 -07:00
parent 5795db9232
commit 83ba038423
4 changed files with 11 additions and 1 deletions

View File

@ -332,6 +332,13 @@ func (c *Context) computeVars(raw *config.RawConfig) error {
val, ok := c.variables[v.Name]
if ok {
vs[n] = val
continue
}
for k, val := range c.variables {
if strings.HasPrefix(k, v.Name+".") {
vs["var."+k] = val
}
}
}
}

View File

@ -1045,7 +1045,8 @@ func TestContextApply_vars(t *testing.T) {
"aws": testProviderFuncFixed(p),
},
Variables: map[string]string{
"foo": "us-west-2",
"foo": "us-west-2",
"amis.us-east-1": "override",
},
})

View File

@ -222,6 +222,7 @@ const testTerraformApplyVarsStr = `
aws_instance.bar:
ID = foo
bar = foo
baz = override
foo = us-west-2
type = aws_instance
aws_instance.foo:

View File

@ -17,4 +17,5 @@ resource "aws_instance" "foo" {
resource "aws_instance" "bar" {
foo = "${var.foo}"
bar = "${lookup(var.amis, var.foo)}"
baz = "${var.amis.us-east-1}"
}