diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index b7636e989..aaa2c69a5 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -1511,6 +1511,40 @@ STATE: } } +func TestContext2Plan_countModuleStaticGrandchild(t *testing.T) { + m := testModule(t, "plan-count-module-static-grandchild") + p := testProvider("aws") + p.DiffFn = testDiffFn + ctx := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + }) + + plan, err := ctx.Plan() + if err != nil { + t.Fatalf("err: %s", err) + } + + actual := strings.TrimSpace(plan.String()) + expected := strings.TrimSpace(` +DIFF: + +module.child.child: + CREATE: aws_instance.foo.0 + CREATE: aws_instance.foo.1 + CREATE: aws_instance.foo.2 + +STATE: + + +`) + if actual != expected { + t.Fatalf("bad:\n%s", actual) + } +} + func TestContext2Plan_countIndex(t *testing.T) { m := testModule(t, "plan-count-index") p := testProvider("aws") diff --git a/terraform/test-fixtures/plan-count-module-static-grandchild/child/child/main.tf b/terraform/test-fixtures/plan-count-module-static-grandchild/child/child/main.tf new file mode 100644 index 000000000..5b75831fd --- /dev/null +++ b/terraform/test-fixtures/plan-count-module-static-grandchild/child/child/main.tf @@ -0,0 +1,5 @@ +variable "value" {} + +resource "aws_instance" "foo" { + count = "${var.value}" +} diff --git a/terraform/test-fixtures/plan-count-module-static-grandchild/child/main.tf b/terraform/test-fixtures/plan-count-module-static-grandchild/child/main.tf new file mode 100644 index 000000000..4dff927d5 --- /dev/null +++ b/terraform/test-fixtures/plan-count-module-static-grandchild/child/main.tf @@ -0,0 +1,6 @@ +variable "value" {} + +module "child" { + source = "./child" + value = "${var.value}" +} diff --git a/terraform/test-fixtures/plan-count-module-static-grandchild/main.tf b/terraform/test-fixtures/plan-count-module-static-grandchild/main.tf new file mode 100644 index 000000000..547bbde9d --- /dev/null +++ b/terraform/test-fixtures/plan-count-module-static-grandchild/main.tf @@ -0,0 +1,6 @@ +variable "foo" { default = "3" } + +module "child" { + source = "./child" + value = "${var.foo}" +}