From aeadb8ca9037806d67f34e2d0e81753bab1f4fbb Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 10 Apr 2020 16:52:47 -0400 Subject: [PATCH] start with a failing test --- terraform/context_plan_test.go | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index cf2c3e021..7a97f7b23 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -5832,3 +5832,47 @@ resource "aws_instance" "foo" { t.Errorf("missing %s change for %s", action, res) } } + +func TestContext2Plan_indexInVar(t *testing.T) { + m := testModuleInline(t, map[string]string{ + "main.tf": ` +module "a" { + count = 1 + source = "./mod" + in = "test" +} + +module "b" { + count = 1 + source = "./mod" + in = length(module.a) +} +`, + "mod/main.tf": ` +resource "aws_instance" "foo" { + foo = var.in +} + +variable "in" { +} + +output"out" { + value = aws_instance.foo.id +} +`, + }) + + p := testProvider("aws") + p.DiffFn = testDiffFn + ctx := testContext2(t, &ContextOpts{ + Config: m, + Providers: map[addrs.Provider]providers.Factory{ + addrs.NewDefaultProvider("aws"): testProviderFuncFixed(p), + }, + }) + + _, diags := ctx.Plan() + if diags.HasErrors() { + t.Fatal(diags.ErrWithWarnings()) + } +}