Add failing test for invalid interpolation

Adding the submodule causes the count variable interpolation to fail.
This commit is contained in:
James Bardin 2017-03-16 10:30:14 -04:00
parent dbdee44215
commit fe5f519817
4 changed files with 49 additions and 0 deletions

View File

@ -658,3 +658,30 @@ func TestContext2Input_hcl(t *testing.T) {
t.Fatalf("bad: \n%s", actualStr) t.Fatalf("bad: \n%s", actualStr)
} }
} }
// adding a list interpolation in fails to interpolate the count variable
func TestContext2Input_submoduleTriggersInvalidCount(t *testing.T) {
input := new(MockUIInput)
m := testModule(t, "input-submodule-count")
p := testProvider("aws")
p.ApplyFn = testApplyFn
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Module: m,
Providers: map[string]ResourceProviderFactory{
"aws": testProviderFuncFixed(p),
},
UIInput: input,
})
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
return c, nil
}
p.ConfigureFn = func(c *ResourceConfig) error {
return nil
}
if err := ctx.Input(InputModeStd); err != nil {
t.Fatalf("err: %s", err)
}
}

View File

@ -0,0 +1,4 @@
module "mod" {
source = "./mod"
count = 2
}

View File

@ -0,0 +1,11 @@
variable "count" {
}
resource "aws_instance" "foo" {
count = "${var.count}"
}
module "submod" {
source = "./submod"
list = ["${aws_instance.foo.*.id}"]
}

View File

@ -0,0 +1,7 @@
variable "list" {
type = "list"
}
resource "aws_instance" "bar" {
count = "${var.list[0]}"
}