From 6bad4e3dc03bbf43a31977c1c33f7e94e5882813 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 18 Dec 2019 15:37:08 -0500 Subject: [PATCH] add an interp that fails during planned destroy Chain some values so that we can get an interpolation that fails if a module input is evaluated during destroy. --- terraform/context_apply_test.go | 1 - .../plan-destroy-interpolated-count/main.tf | 13 +++++++++++-- .../plan-destroy-interpolated-count/mod/main.tf | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 terraform/testdata/plan-destroy-interpolated-count/mod/main.tf diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 1de9e380b..f344a42b0 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -10521,7 +10521,6 @@ func TestContext2Apply_plannedDestroyInterpolatedCount(t *testing.T) { } ctxOpts.ProviderResolver = providerResolver - ctxOpts.Destroy = true ctx, diags = NewContext(ctxOpts) if diags.HasErrors() { t.Fatalf("err: %s", diags.Err()) diff --git a/terraform/testdata/plan-destroy-interpolated-count/main.tf b/terraform/testdata/plan-destroy-interpolated-count/main.tf index b4ef77aba..ac0dadbf8 100644 --- a/terraform/testdata/plan-destroy-interpolated-count/main.tf +++ b/terraform/testdata/plan-destroy-interpolated-count/main.tf @@ -3,9 +3,18 @@ variable "list" { } resource "aws_instance" "a" { - count = "${length(var.list)}" + count = length(var.list) +} + +locals { + ids = aws_instance.a[*].id +} + +module "empty" { + source = "./mod" + input = zipmap(var.list, local.ids) } output "out" { - value = "${aws_instance.a.*.id}" + value = aws_instance.a[*].id } diff --git a/terraform/testdata/plan-destroy-interpolated-count/mod/main.tf b/terraform/testdata/plan-destroy-interpolated-count/mod/main.tf new file mode 100644 index 000000000..682e0f0db --- /dev/null +++ b/terraform/testdata/plan-destroy-interpolated-count/mod/main.tf @@ -0,0 +1,2 @@ +variable "input" { +}