@@ -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 value )
414+ + password = (sensitive)
415415 + user = "not-secret"
416416 }
417417 + id = (known after apply)
418- + password = (sensitive value )
418+ + password = (sensitive)
419419 }
420420` ,
421421 },
@@ -2210,6 +2210,93 @@ func TestResourceChange_nested_attributes(t *testing.T) {
22102210 + attr = "hello"
22112211 }
22122212 }
2213+ ` ,
2214+ },
2215+ "deletion" : {
2216+ Action : plans .Delete ,
2217+ Mode : addrs .ManagedResourceMode ,
2218+ Before : cty .ObjectVal (map [string ]cty.Value {
2219+ "id" : cty .UnknownVal (cty .String ),
2220+ "nested_single" : cty .ObjectVal (map [string ]cty.Value {
2221+ "attr" : cty .StringVal ("hello" ),
2222+ }),
2223+ "nested_list" : cty .ListVal ([]cty.Value {
2224+ cty .ObjectVal (map [string ]cty.Value {
2225+ "attr" : cty .StringVal ("hello" ),
2226+ }),
2227+ }),
2228+ }),
2229+ After : cty .NullVal (cty .EmptyObject ),
2230+ Schema : & configschema.Block {
2231+ Attributes : map [string ]* configschema.Attribute {
2232+ "id" : {Type : cty .String , Optional : true , Computed : true },
2233+ "nested_single" : {NestedType : & configschema.Object {
2234+ Attributes : map [string ]* configschema.Attribute {
2235+ "attr" : {Type : cty .String , Optional : true },
2236+ },
2237+ Nesting : configschema .NestingSingle ,
2238+ }, Optional : true },
2239+ "nested_list" : {NestedType : & configschema.Object {
2240+ Attributes : map [string ]* configschema.Attribute {
2241+ "attr" : {Type : cty .String , Optional : true },
2242+ },
2243+ Nesting : configschema .NestingList ,
2244+ }},
2245+ },
2246+ },
2247+ ExpectedOutput : ` # test_instance.example will be destroyed
2248+ - resource "test_instance" "example" {
2249+ - id = (known after apply) -> null
2250+ - nested_list = [
2251+ - {
2252+ - attr = "hello" -> null
2253+ },
2254+ ] -> null
2255+ - nested_single = {
2256+ - attr = "hello" -> null
2257+ } -> null
2258+ }
2259+ ` ,
2260+ },
2261+ "force replacement with changed after subattr" : {
2262+ Action : plans .DeleteThenCreate ,
2263+ ActionReason : plans .ResourceInstanceReplaceBecauseCannotUpdate ,
2264+ Mode : addrs .ManagedResourceMode ,
2265+ Before : cty .ObjectVal (map [string ]cty.Value {
2266+ "id" : cty .StringVal ("id" ),
2267+ "nested_single" : cty .ObjectVal (map [string ]cty.Value {
2268+ "attr" : cty .StringVal ("hello" ),
2269+ }),
2270+ }),
2271+ After : cty .ObjectVal (map [string ]cty.Value {
2272+ "id" : cty .StringVal ("id" ),
2273+ "nested_single" : cty .ObjectVal (map [string ]cty.Value {
2274+ "attr" : cty .StringVal ("changed" ),
2275+ }),
2276+ }),
2277+ Schema : & configschema.Block {
2278+ Attributes : map [string ]* configschema.Attribute {
2279+ "id" : {Type : cty .String , Optional : true , Computed : true },
2280+ "nested_single" : {NestedType : & configschema.Object {
2281+ Attributes : map [string ]* configschema.Attribute {
2282+ "attr" : {Type : cty .String , Optional : true },
2283+ },
2284+ Nesting : configschema .NestingSingle ,
2285+ }, Optional : true },
2286+ },
2287+ },
2288+ RequiredReplace : cty .NewPathSet (cty.Path {
2289+ cty.GetAttrStep {Name : "nested_single" },
2290+ }, cty.Path {
2291+ cty.GetAttrStep {Name : "nested_list" },
2292+ }),
2293+ ExpectedOutput : ` # test_instance.example must be replaced
2294+ -/+ resource "test_instance" "example" {
2295+ id = "id"
2296+ ~ nested_single = { # forces replacement
2297+ ~ attr = "hello" -> "changed"
2298+ }
2299+ }
22132300` ,
22142301 },
22152302 }
@@ -3100,7 +3187,7 @@ func TestResourceChange_nestedSet(t *testing.T) {
31003187 ExpectedOutput : ` # test_instance.example will be created
31013188 + resource "test_instance" "example" {
31023189 + ami = "ami-AFTER"
3103- + disks = (sensitive value )
3190+ + disks = (sensitive)
31043191 + id = "i-02ae66f368e8518a9"
31053192
31063193 + root_block_device {
@@ -3198,7 +3285,7 @@ func TestResourceChange_nestedSet(t *testing.T) {
31983285 ~ ami = "ami-BEFORE" -> "ami-AFTER"
31993286 # Warning: this attribute value will be marked as sensitive and will not
32003287 # display in UI output after applying this change.
3201- ~ disks = (sensitive value )
3288+ ~ disks = (sensitive)
32023289 id = "i-02ae66f368e8518a9"
32033290
32043291 + root_block_device {
@@ -3249,7 +3336,7 @@ func TestResourceChange_nestedSet(t *testing.T) {
32493336 ~ ami = "ami-BEFORE" -> "ami-AFTER"
32503337 # Warning: this attribute value will be marked as sensitive and will not
32513338 # display in UI output after applying this change. The value is unchanged.
3252- ~ disks = (sensitive value )
3339+ ~ disks = (sensitive)
32533340 id = "i-02ae66f368e8518a9"
32543341 }
32553342` ,
@@ -5797,7 +5884,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
57975884 ),
57985885 ExpectedOutput : ` # test_instance.example must be replaced
57995886-/+ resource "test_instance" "example" {
5800- ~ ami = (sensitive value ) # forces replacement
5887+ ~ ami = (sensitive) # forces replacement
58015888 id = "i-02ae66f368e8518a9"
58025889 }
58035890` ,
@@ -5840,7 +5927,7 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
58405927 ExpectedOutput : ` # test_instance.example must be replaced
58415928-/+ resource "test_instance" "example" {
58425929 ~ conn_info = { # forces replacement
5843- ~ password = (sensitive value )
5930+ ~ password = (sensitive)
58445931 # (1 unchanged attribute hidden)
58455932 }
58465933 id = "i-02ae66f368e8518a9"
@@ -6097,7 +6184,7 @@ func TestOutputChanges(t *testing.T) {
60976184 },
60986185 `
60996186 ~ a = 1 -> 2
6100- ~ b = (sensitive value )
6187+ ~ b = (sensitive)
61016188 ~ c = false -> true` ,
61026189 },
61036190 }
0 commit comments