From 354a74349ad3fce0f70be45b45075ffc61d90040 Mon Sep 17 00:00:00 2001 From: Liam Cervante Date: Fri, 16 Dec 2022 15:15:04 +0000 Subject: [PATCH] backport of commit efb3f3038c9c2ba9ac4c41625f74fb06f02e366e --- internal/terraform/eval_variable_test.go | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/internal/terraform/eval_variable_test.go b/internal/terraform/eval_variable_test.go index 702c7a8a31b0..e6e152ba259b 100644 --- a/internal/terraform/eval_variable_test.go +++ b/internal/terraform/eval_variable_test.go @@ -180,6 +180,18 @@ func TestPrepareFinalInputVariableValue(t *testing.T) { } ] } + // https://github.com/hashicorp/terraform/issues/32396 + // This variable was originally introduced to test the behaviour of the + // dynamic type constraint. You should be able to set primitive types in + // the list consistently. + variable "list_with_nested_collections_dynamic_with_default" { + type = list( + object({ + name = optional(string, "default") + taints = optional(list(map(any)), []) + }) + ) + } ` cfg := testModuleInline(t, map[string]string{ "main.tf": cfgSrc, @@ -714,6 +726,39 @@ func TestPrepareFinalInputVariableValue(t *testing.T) { }), ``, }, + { + "list_with_nested_collections_dynamic_with_default", + cty.TupleVal([]cty.Value{ + cty.ObjectVal(map[string]cty.Value{ + "name": cty.StringVal("default"), + }), + cty.ObjectVal(map[string]cty.Value{ + "name": cty.StringVal("complex"), + "taints": cty.ListVal([]cty.Value{ + cty.MapVal(map[string]cty.Value{ + "key": cty.StringVal("my_key"), + "value": cty.StringVal("my_value"), + }), + }), + }), + }), + cty.ListVal([]cty.Value{ + cty.ObjectVal(map[string]cty.Value{ + "name": cty.StringVal("default"), + "taints": cty.ListValEmpty(cty.Map(cty.String)), + }), + cty.ObjectVal(map[string]cty.Value{ + "name": cty.StringVal("complex"), + "taints": cty.ListVal([]cty.Value{ + cty.MapVal(map[string]cty.Value{ + "key": cty.StringVal("my_key"), + "value": cty.StringVal("my_value"), + }), + }), + }), + }), + ``, + }, // sensitive {