diff --git a/terraform/evaluate.go b/terraform/evaluate.go index 9fafff8411..c8ee603049 100644 --- a/terraform/evaluate.go +++ b/terraform/evaluate.go @@ -974,15 +974,12 @@ func getValMarks(schema *configschema.Block, val cty.Value, path cty.Path) []cty switch blockS.Nesting { case configschema.NestingSingle, configschema.NestingGroup: pvm = append(pvm, getValMarks(&blockS.Block, blockV, blockPath)...) - case configschema.NestingList, configschema.NestingMap: + case configschema.NestingList, configschema.NestingMap, configschema.NestingSet: for it := blockV.ElementIterator(); it.Next(); { idx, blockEV := it.Element() morePaths := getValMarks(&blockS.Block, blockEV, append(blockPath, cty.IndexStep{Key: idx})) pvm = append(pvm, morePaths...) } - case configschema.NestingSet: - // TODO - continue default: panic(fmt.Sprintf("unsupported nesting mode %s", blockS.Nesting)) } diff --git a/terraform/evaluate_test.go b/terraform/evaluate_test.go index 519a9ab2c2..3f32c5ffa6 100644 --- a/terraform/evaluate_test.go +++ b/terraform/evaluate_test.go @@ -135,7 +135,7 @@ func TestEvaluatorGetResource(t *testing.T) { }.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance), &states.ResourceInstanceObjectSrc{ Status: states.ObjectReady, - AttrsJSON: []byte(`{"id":"foo", "nesting_list": [{"sensitive_value":"abc"}], "nesting_map": {"foo":{"foo":"x"}}, "value":"hello"}`), + AttrsJSON: []byte(`{"id":"foo", "nesting_list": [{"sensitive_value":"abc"}], "nesting_map": {"foo":{"foo":"x"}}, "nesting_set": [{"baz":"abc"}], "nesting_single": {"boop":"abc"}, "value":"hello"}`), }, addrs.AbsProviderConfig{ Provider: addrs.NewDefaultProvider("test"), @@ -206,6 +206,22 @@ func TestEvaluatorGetResource(t *testing.T) { }, Nesting: configschema.NestingMap, }, + "nesting_set": { + Block: configschema.Block{ + Attributes: map[string]*configschema.Attribute{ + "baz": {Type: cty.String, Optional: true, Sensitive: true}, + }, + }, + Nesting: configschema.NestingSet, + }, + "nesting_single": { + Block: configschema.Block{ + Attributes: map[string]*configschema.Attribute{ + "boop": {Type: cty.String, Optional: true, Sensitive: true}, + }, + }, + Nesting: configschema.NestingSingle, + }, }, }, }, @@ -230,6 +246,14 @@ func TestEvaluatorGetResource(t *testing.T) { "nesting_map": cty.MapVal(map[string]cty.Value{ "foo": cty.ObjectVal(map[string]cty.Value{"foo": cty.StringVal("x").Mark("sensitive")}), }), + "nesting_set": cty.SetVal([]cty.Value{ + cty.ObjectVal(map[string]cty.Value{ + "baz": cty.StringVal("abc").Mark("sensitive"), + }), + }), + "nesting_single": cty.ObjectVal(map[string]cty.Value{ + "boop": cty.StringVal("abc").Mark("sensitive"), + }), "value": cty.StringVal("hello").Mark("sensitive"), })