Skip to content

Commit e91f99a

Browse files
author
The Terraform Team
authored
Merge bd744ad into backport/brandonc/nested_attr_sensitive/repeatedly-tidy-doe
2 parents 31dd52c + bd744ad commit e91f99a

File tree

11 files changed

+67
-63
lines changed

11 files changed

+67
-63
lines changed

internal/command/console_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ func TestConsole_variables(t *testing.T) {
172172
commands := map[string]string{
173173
"var.foo\n": "\"bar\"\n",
174174
"var.snack\n": "\"popcorn\"\n",
175-
"var.secret_snack\n": "(sensitive)\n",
176-
"local.snack_bar\n": "[\n \"popcorn\",\n (sensitive),\n]\n",
175+
"var.secret_snack\n": "(sensitive value)\n",
176+
"local.snack_bar\n": "[\n \"popcorn\",\n (sensitive value),\n]\n",
177177
}
178178

179179
args := []string{}

internal/command/format/diff.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ type blockBodyDiffResult struct {
274274
skippedBlocks int
275275
}
276276

277-
const forcesNewResourceCaption = " [red]# forces replacement[reset]"
277+
const (
278+
forcesNewResourceCaption = " [red]# forces replacement[reset]"
279+
sensitiveCaption = "(sensitive value)"
280+
)
278281

279282
// writeBlockBodyDiff writes attribute or block differences
280283
// and returns true if any differences were found and written
@@ -416,7 +419,7 @@ func (p *blockBodyDiffPrinter) writeAttrDiff(name string, attrS *configschema.At
416419
p.buf.WriteString(" = ")
417420

418421
if attrS.Sensitive {
419-
p.buf.WriteString("(sensitive)")
422+
p.buf.WriteString(sensitiveCaption)
420423
if p.pathForcesNewResource(path) {
421424
p.buf.WriteString(p.color.Color(forcesNewResourceCaption))
422425
}
@@ -459,7 +462,8 @@ func (p *blockBodyDiffPrinter) writeNestedAttrDiff(
459462
// Then schema of the attribute itself can be marked sensitive, or the values assigned
460463
sensitive := attrWithNestedS.Sensitive || old.HasMark(marks.Sensitive) || new.HasMark(marks.Sensitive)
461464
if sensitive {
462-
p.buf.WriteString(" = (sensitive)")
465+
p.buf.WriteString(" = ")
466+
p.buf.WriteString(sensitiveCaption)
463467

464468
if p.pathForcesNewResource(path) {
465469
p.buf.WriteString(p.color.Color(forcesNewResourceCaption))
@@ -742,7 +746,7 @@ func (p *blockBodyDiffPrinter) writeNestedBlockDiffs(name string, blockS *config
742746

743747
// If either the old or the new value is marked,
744748
// Display a special diff because it is irrelevant
745-
// to list all obfuscated attributes as (sensitive)
749+
// to list all obfuscated attributes as (sensitive value)
746750
if old.HasMark(marks.Sensitive) || new.HasMark(marks.Sensitive) {
747751
p.writeSensitiveNestedBlockDiff(name, old, new, indent, blankBefore, path)
748752
return 0
@@ -1025,7 +1029,7 @@ func (p *blockBodyDiffPrinter) writeNestedBlockDiff(name string, label *string,
10251029
func (p *blockBodyDiffPrinter) writeValue(val cty.Value, action plans.Action, indent int) {
10261030
// Could check specifically for the sensitivity marker
10271031
if val.HasMark(marks.Sensitive) {
1028-
p.buf.WriteString("(sensitive)")
1032+
p.buf.WriteString(sensitiveCaption)
10291033
return
10301034
}
10311035

@@ -1193,7 +1197,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
11931197
// values are known and non-null.
11941198
if old.IsKnown() && new.IsKnown() && !old.IsNull() && !new.IsNull() && typesEqual {
11951199
if old.HasMark(marks.Sensitive) || new.HasMark(marks.Sensitive) {
1196-
p.buf.WriteString("(sensitive)")
1200+
p.buf.WriteString(sensitiveCaption)
11971201
if p.pathForcesNewResource(path) {
11981202
p.buf.WriteString(p.color.Color(forcesNewResourceCaption))
11991203
}
@@ -1564,7 +1568,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
15641568
case plans.Create, plans.NoOp:
15651569
v := new.Index(kV)
15661570
if v.HasMark(marks.Sensitive) {
1567-
p.buf.WriteString("(sensitive)")
1571+
p.buf.WriteString(sensitiveCaption)
15681572
} else {
15691573
p.writeValue(v, action, indent+4)
15701574
}
@@ -1574,7 +1578,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
15741578
p.writeValueDiff(oldV, newV, indent+4, path)
15751579
default:
15761580
if oldV.HasMark(marks.Sensitive) || newV.HasMark(marks.Sensitive) {
1577-
p.buf.WriteString("(sensitive)")
1581+
p.buf.WriteString(sensitiveCaption)
15781582
} else {
15791583
p.writeValueDiff(oldV, newV, indent+4, path)
15801584
}

internal/command/format/diff_test.go

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,11 @@ new line
411411
ExpectedOutput: ` # test_instance.example will be created
412412
+ resource "test_instance" "example" {
413413
+ conn_info = {
414-
+ password = (sensitive)
414+
+ password = (sensitive value)
415415
+ user = "not-secret"
416416
}
417417
+ id = (known after apply)
418-
+ password = (sensitive)
418+
+ password = (sensitive value)
419419
}
420420
`,
421421
},
@@ -3048,7 +3048,7 @@ func TestResourceChange_nestedSet(t *testing.T) {
30483048
ExpectedOutput: ` # test_instance.example will be created
30493049
+ resource "test_instance" "example" {
30503050
+ ami = "ami-AFTER"
3051-
+ disks = (sensitive)
3051+
+ disks = (sensitive value)
30523052
+ id = "i-02ae66f368e8518a9"
30533053
30543054
+ root_block_device {
@@ -3146,7 +3146,7 @@ func TestResourceChange_nestedSet(t *testing.T) {
31463146
~ ami = "ami-BEFORE" -> "ami-AFTER"
31473147
# Warning: this attribute value will be marked as sensitive and will not
31483148
# display in UI output after applying this change.
3149-
~ disks = (sensitive)
3149+
~ disks = (sensitive value)
31503150
id = "i-02ae66f368e8518a9"
31513151
31523152
+ root_block_device {
@@ -3197,7 +3197,7 @@ func TestResourceChange_nestedSet(t *testing.T) {
31973197
~ ami = "ami-BEFORE" -> "ami-AFTER"
31983198
# Warning: this attribute value will be marked as sensitive and will not
31993199
# display in UI output after applying this change. The value is unchanged.
3200-
~ disks = (sensitive)
3200+
~ disks = (sensitive value)
32013201
id = "i-02ae66f368e8518a9"
32023202
}
32033203
`,
@@ -3965,7 +3965,7 @@ func TestResourceChange_nestedMap(t *testing.T) {
39653965
~ ami = "ami-BEFORE" -> "ami-AFTER"
39663966
~ disks = {
39673967
+ "disk_a" = {
3968-
+ mount_point = (sensitive)
3968+
+ mount_point = (sensitive value)
39693969
+ size = "50GB"
39703970
},
39713971
}
@@ -5728,18 +5728,18 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
57285728
},
57295729
ExpectedOutput: ` # test_instance.example will be created
57305730
+ resource "test_instance" "example" {
5731-
+ ami = (sensitive)
5731+
+ ami = (sensitive value)
57325732
+ id = "i-02ae66f368e8518a9"
57335733
+ list_field = [
57345734
+ "hello",
5735-
+ (sensitive),
5735+
+ (sensitive value),
57365736
+ "!",
57375737
]
57385738
+ map_key = {
57395739
+ "breakfast" = 800
5740-
+ "dinner" = (sensitive)
5740+
+ "dinner" = (sensitive value)
57415741
}
5742-
+ map_whole = (sensitive)
5742+
+ map_whole = (sensitive value)
57435743
57445744
+ nested_block_list {
57455745
# At least one attribute in this block is (or was) sensitive,
@@ -5882,29 +5882,29 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
58825882
~ resource "test_instance" "example" {
58835883
# Warning: this attribute value will no longer be marked as sensitive
58845884
# after applying this change.
5885-
~ ami = (sensitive)
5885+
~ ami = (sensitive value)
58865886
id = "i-02ae66f368e8518a9"
58875887
~ list_field = [
58885888
# (1 unchanged element hidden)
58895889
"friends",
5890-
- (sensitive),
5890+
- (sensitive value),
58915891
+ ".",
58925892
]
58935893
~ map_key = {
58945894
# Warning: this attribute value will no longer be marked as sensitive
58955895
# after applying this change.
5896-
~ "dinner" = (sensitive)
5896+
~ "dinner" = (sensitive value)
58975897
# (1 unchanged element hidden)
58985898
}
58995899
# Warning: this attribute value will no longer be marked as sensitive
59005900
# after applying this change.
5901-
~ map_whole = (sensitive)
5901+
~ map_whole = (sensitive value)
59025902
# Warning: this attribute value will no longer be marked as sensitive
59035903
# after applying this change.
5904-
~ some_number = (sensitive)
5904+
~ some_number = (sensitive value)
59055905
# Warning: this attribute value will no longer be marked as sensitive
59065906
# after applying this change.
5907-
~ special = (sensitive)
5907+
~ special = (sensitive value)
59085908
59095909
# Warning: this block will no longer be marked as sensitive
59105910
# after applying this change.
@@ -6007,18 +6007,18 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
60076007
id = "i-02ae66f368e8518a9"
60086008
~ list_field = [
60096009
- "hello",
6010-
+ (sensitive),
6010+
+ (sensitive value),
60116011
"friends",
60126012
]
60136013
~ map_key = {
60146014
~ "breakfast" = 800 -> 700
60156015
# Warning: this attribute value will be marked as sensitive and will not
60166016
# display in UI output after applying this change.
6017-
~ "dinner" = (sensitive)
6017+
~ "dinner" = (sensitive value)
60186018
}
60196019
# Warning: this attribute value will be marked as sensitive and will not
60206020
# display in UI output after applying this change.
6021-
~ map_whole = (sensitive)
6021+
~ map_whole = (sensitive value)
60226022
60236023
# Warning: this block will be marked as sensitive and will not
60246024
# display in UI output after applying this change.
@@ -6143,15 +6143,15 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
61436143
~ ami = (sensitive value)
61446144
id = "i-02ae66f368e8518a9"
61456145
~ list_field = [
6146-
- (sensitive),
6147-
+ (sensitive),
6146+
- (sensitive value),
6147+
+ (sensitive value),
61486148
"friends",
61496149
]
61506150
~ map_key = {
6151-
~ "dinner" = (sensitive)
6151+
~ "dinner" = (sensitive value)
61526152
# (1 unchanged element hidden)
61536153
}
6154-
~ map_whole = (sensitive)
6154+
~ map_whole = (sensitive value)
61556155
61566156
~ nested_block_map {
61576157
# At least one attribute in this block is (or was) sensitive,
@@ -6289,29 +6289,29 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
62896289
~ resource "test_instance" "example" {
62906290
# Warning: this attribute value will no longer be marked as sensitive
62916291
# after applying this change. The value is unchanged.
6292-
~ ami = (sensitive)
6292+
~ ami = (sensitive value)
62936293
id = "i-02ae66f368e8518a9"
62946294
~ list_field = [
62956295
# (1 unchanged element hidden)
62966296
"friends",
6297-
- (sensitive),
6297+
- (sensitive value),
62986298
+ "!",
62996299
]
63006300
~ map_key = {
63016301
# Warning: this attribute value will no longer be marked as sensitive
63026302
# after applying this change. The value is unchanged.
6303-
~ "dinner" = (sensitive)
6303+
~ "dinner" = (sensitive value)
63046304
# (1 unchanged element hidden)
63056305
}
63066306
# Warning: this attribute value will no longer be marked as sensitive
63076307
# after applying this change. The value is unchanged.
6308-
~ map_whole = (sensitive)
6308+
~ map_whole = (sensitive value)
63096309
# Warning: this attribute value will no longer be marked as sensitive
63106310
# after applying this change. The value is unchanged.
6311-
~ some_number = (sensitive)
6311+
~ some_number = (sensitive value)
63126312
# Warning: this attribute value will no longer be marked as sensitive
63136313
# after applying this change. The value is unchanged.
6314-
~ special = (sensitive)
6314+
~ special = (sensitive value)
63156315
63166316
# Warning: this block will no longer be marked as sensitive
63176317
# after applying this change.
@@ -6410,17 +6410,17 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
64106410
},
64116411
ExpectedOutput: ` # test_instance.example will be destroyed
64126412
- resource "test_instance" "example" {
6413-
- ami = (sensitive) -> null
6413+
- ami = (sensitive value) -> null
64146414
- id = "i-02ae66f368e8518a9" -> null
64156415
- list_field = [
64166416
- "hello",
6417-
- (sensitive),
6417+
- (sensitive value),
64186418
] -> null
64196419
- map_key = {
64206420
- "breakfast" = 800
6421-
- "dinner" = (sensitive)
6421+
- "dinner" = (sensitive value)
64226422
} -> null
6423-
- map_whole = (sensitive) -> null
6423+
- map_whole = (sensitive value) -> null
64246424
64256425
- nested_block_set {
64266426
# At least one attribute in this block is (or was) sensitive,
@@ -6492,7 +6492,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
64926492
),
64936493
ExpectedOutput: ` # test_instance.example must be replaced
64946494
-/+ resource "test_instance" "example" {
6495-
~ ami = (sensitive) # forces replacement
6495+
~ ami = (sensitive value) # forces replacement
64966496
id = "i-02ae66f368e8518a9"
64976497
64986498
~ nested_block_set { # forces replacement
@@ -6524,7 +6524,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
65246524
),
65256525
ExpectedOutput: ` # test_instance.example must be replaced
65266526
-/+ resource "test_instance" "example" {
6527-
~ ami = (sensitive) # forces replacement
6527+
~ ami = (sensitive value) # forces replacement
65286528
id = "i-02ae66f368e8518a9"
65296529
}
65306530
`,
@@ -6567,7 +6567,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
65676567
ExpectedOutput: ` # test_instance.example must be replaced
65686568
-/+ resource "test_instance" "example" {
65696569
~ conn_info = { # forces replacement
6570-
~ password = (sensitive)
6570+
~ password = (sensitive value)
65716571
# (1 unchanged attribute hidden)
65726572
}
65736573
id = "i-02ae66f368e8518a9"
@@ -6824,7 +6824,7 @@ func TestOutputChanges(t *testing.T) {
68246824
},
68256825
`
68266826
~ a = 1 -> 2
6827-
~ b = (sensitive)
6827+
~ b = (sensitive value)
68286828
~ c = false -> true`,
68296829
},
68306830
}

internal/repl/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func FormatValue(v cty.Value, indent int) string {
1818
return "(known after apply)"
1919
}
2020
if v.HasMark(marks.Sensitive) {
21-
return "(sensitive)"
21+
return "(sensitive value)"
2222
}
2323
if v.IsNull() {
2424
ty := v.Type()

internal/repl/format_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ EOT_`,
171171
`toset([])`,
172172
},
173173
{
174-
cty.StringVal("sensitive value").Mark(marks.Sensitive),
175-
"(sensitive)",
174+
cty.StringVal("a sensitive value").Mark(marks.Sensitive),
175+
"(sensitive value)",
176176
},
177177
}
178178

website/docs/language/expressions/function-calls.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ the `keys()` function will result in a list that is sensitive:
6363
```shell
6464
> local.baz
6565
{
66-
"a" = (sensitive)
66+
"a" = (sensitive value)
6767
"b" = "dog"
6868
}
6969
> keys(local.baz)
70-
(sensitive)
70+
(sensitive value)
7171
```
7272

7373
## When Terraform Calls Functions

website/docs/language/expressions/references.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Note that unlike `count`, splat expressions are _not_ directly applicable to res
292292

293293
When defining the schema for a resource type, a provider developer can mark
294294
certain attributes as _sensitive_, in which case Terraform will show a
295-
placeholder marker `(sensitive)` instead of the actual value when rendering
295+
placeholder marker `(sensitive value)` instead of the actual value when rendering
296296
a plan involving that attribute.
297297

298298
A provider attribute marked as sensitive behaves similarly to an

website/docs/language/functions/nonsensitive.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ the local value `mixed_content`, with a valid JSON string assigned to
9191

9292
```
9393
> var.mixed_content_json
94-
(sensitive)
94+
(sensitive value)
9595
> local.mixed_content
96-
(sensitive)
96+
(sensitive value)
9797
> local.mixed_content["password"]
98-
(sensitive)
98+
(sensitive value)
9999
> nonsensitive(local.mixed_content["username"])
100100
"zqb"
101101
> nonsensitive("clear")

0 commit comments

Comments
 (0)