diff --git a/terraform/context_validate_test.go b/terraform/context_validate_test.go index 5d80f0333..58d12ef9e 100644 --- a/terraform/context_validate_test.go +++ b/terraform/context_validate_test.go @@ -821,3 +821,29 @@ func TestContext2Validate_interpolateComputedModuleVarDef(t *testing.T) { t.Fatal("err:", e) } } + +// Computed values are lost when a map is output from a module +func TestContext2Validate_interpolateMap(t *testing.T) { + input := new(MockUIInput) + + m := testModule(t, "issue-9549") + p := testProvider("null") + p.ApplyFn = testApplyFn + p.DiffFn = testDiffFn + + ctx := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "template": testProviderFuncFixed(p), + }, + UIInput: input, + }) + + w, e := ctx.Validate() + if w != nil { + t.Log("warnings:", w) + } + if e != nil { + t.Fatal("err:", e) + } +} diff --git a/terraform/test-fixtures/issue-9549/main.tf b/terraform/test-fixtures/issue-9549/main.tf new file mode 100644 index 000000000..b60a7c87c --- /dev/null +++ b/terraform/test-fixtures/issue-9549/main.tf @@ -0,0 +1,7 @@ +module "mod" { + source = "./mod" +} + +resource "template_file" "root_template" { + template = "ext: ${module.mod.base_config["base_template"]}" +} diff --git a/terraform/test-fixtures/issue-9549/mod/main.tf b/terraform/test-fixtures/issue-9549/mod/main.tf new file mode 100644 index 000000000..169a39b86 --- /dev/null +++ b/terraform/test-fixtures/issue-9549/mod/main.tf @@ -0,0 +1,12 @@ +resource "template_file" "example" { + template = "template text" +} + +output "base_config" { + value = { + base_template = "${template_file.example.rendered}" + + # without this we fail with no entries + extra = "value" + } +}