terraform: mapping overrides work
This commit is contained in:
parent
5795db9232
commit
83ba038423
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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}"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue