diff --git a/command/format/diff.go b/command/format/diff.go index b274f5a0d5..b7b5b6ae28 100644 --- a/command/format/diff.go +++ b/command/format/diff.go @@ -1070,24 +1070,17 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa return case ty.IsMapType(): + if old.IsMarked() || new.IsMarked() { + p.buf.WriteString("(sensitive)") + return + } + p.buf.WriteString("{") if p.pathForcesNewResource(path) { p.buf.WriteString(p.color.Color(forcesNewResourceCaption)) } p.buf.WriteString("\n") - // If the whole map is marked, we need to show our - // sensitive block warning rather than attempt to iterate - // through a marked map - if old.IsMarked() || new.IsMarked() { - p.buf.WriteString(strings.Repeat(" ", indent+2)) - p.buf.WriteString("# This map is (or was) sensitive and will not be displayed") - p.buf.WriteString("\n") - p.buf.WriteString(strings.Repeat(" ", indent)) - p.buf.WriteString("}") - return - } - var allKeys []string keyLen := 0 for it := old.ElementIterator(); it.Next(); { diff --git a/command/format/diff_test.go b/command/format/diff_test.go index ffb21e644f..541770200b 100644 --- a/command/format/diff_test.go +++ b/command/format/diff_test.go @@ -3791,9 +3791,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { } # Warning: this attribute value will no longer be marked as sensitive # after applying this change - ~ map_whole = { - # This map is (or was) sensitive and will not be displayed - } + ~ map_whole = (sensitive) # Warning: this attribute value will no longer be marked as sensitive # after applying this change ~ some_number = (sensitive) @@ -3880,9 +3878,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { } # Warning: this attribute value will be marked as sensitive and will # not display in UI output after applying this change - ~ map_whole = { - # This map is (or was) sensitive and will not be displayed - } + ~ map_whole = (sensitive) } `, }, @@ -3981,9 +3977,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { ~ "dinner" = (sensitive) # (1 unchanged element hidden) } - ~ map_whole = { - # This map is (or was) sensitive and will not be displayed - } + ~ map_whole = (sensitive) } `, },