@@ -2633,6 +2633,56 @@ func TestResourceChange_nestedList(t *testing.T) {
26332633 ~ attr = "y" -> "z"
26342634 }
26352635 }
2636+ ` ,
2637+ },
2638+ "in-place update - unknown" : {
2639+ Action : plans .Update ,
2640+ Mode : addrs .ManagedResourceMode ,
2641+ Before : cty .ObjectVal (map [string ]cty.Value {
2642+ "id" : cty .StringVal ("i-02ae66f368e8518a9" ),
2643+ "ami" : cty .StringVal ("ami-BEFORE" ),
2644+ "disks" : cty .ListVal ([]cty.Value {
2645+ cty .ObjectVal (map [string ]cty.Value {
2646+ "mount_point" : cty .StringVal ("/var/diska" ),
2647+ "size" : cty .StringVal ("50GB" ),
2648+ }),
2649+ }),
2650+ "root_block_device" : cty .ListVal ([]cty.Value {
2651+ cty .ObjectVal (map [string ]cty.Value {
2652+ "volume_type" : cty .StringVal ("gp2" ),
2653+ "new_field" : cty .StringVal ("new_value" ),
2654+ }),
2655+ }),
2656+ }),
2657+ After : cty .ObjectVal (map [string ]cty.Value {
2658+ "id" : cty .StringVal ("i-02ae66f368e8518a9" ),
2659+ "ami" : cty .StringVal ("ami-AFTER" ),
2660+ "disks" : cty .UnknownVal (cty .List (cty .Object (map [string ]cty.Type {
2661+ "mount_point" : cty .String ,
2662+ "size" : cty .String ,
2663+ }))),
2664+ "root_block_device" : cty .ListVal ([]cty.Value {
2665+ cty .ObjectVal (map [string ]cty.Value {
2666+ "volume_type" : cty .StringVal ("gp2" ),
2667+ "new_field" : cty .StringVal ("new_value" ),
2668+ }),
2669+ }),
2670+ }),
2671+ RequiredReplace : cty .NewPathSet (),
2672+ Schema : testSchemaPlus (configschema .NestingList ),
2673+ ExpectedOutput : ` # test_instance.example will be updated in-place
2674+ ~ resource "test_instance" "example" {
2675+ ~ ami = "ami-BEFORE" -> "ami-AFTER"
2676+ ~ disks = [
2677+ ~ {
2678+ - mount_point = "/var/diska" -> null
2679+ - size = "50GB" -> null
2680+ },
2681+ ] -> (known after apply)
2682+ id = "i-02ae66f368e8518a9"
2683+
2684+ # (1 unchanged block hidden)
2685+ }
26362686` ,
26372687 },
26382688 }
@@ -2893,7 +2943,8 @@ func TestResourceChange_nestedSet(t *testing.T) {
28932943 ExpectedOutput : ` # test_instance.example will be updated in-place
28942944 ~ resource "test_instance" "example" {
28952945 ~ ami = "ami-BEFORE" -> "ami-AFTER"
2896- + disks = []
2946+ + disks = [
2947+ ]
28972948 id = "i-02ae66f368e8518a9"
28982949 }
28992950` ,
@@ -2952,6 +3003,56 @@ func TestResourceChange_nestedSet(t *testing.T) {
29523003 - volume_type = "gp2" -> null
29533004 }
29543005 }
3006+ ` ,
3007+ },
3008+ "in-place update - unknown" : {
3009+ Action : plans .Update ,
3010+ Mode : addrs .ManagedResourceMode ,
3011+ Before : cty .ObjectVal (map [string ]cty.Value {
3012+ "id" : cty .StringVal ("i-02ae66f368e8518a9" ),
3013+ "ami" : cty .StringVal ("ami-BEFORE" ),
3014+ "disks" : cty .SetVal ([]cty.Value {
3015+ cty .ObjectVal (map [string ]cty.Value {
3016+ "mount_point" : cty .StringVal ("/var/diska" ),
3017+ "size" : cty .StringVal ("50GB" ),
3018+ }),
3019+ }),
3020+ "root_block_device" : cty .SetVal ([]cty.Value {
3021+ cty .ObjectVal (map [string ]cty.Value {
3022+ "volume_type" : cty .StringVal ("gp2" ),
3023+ "new_field" : cty .StringVal ("new_value" ),
3024+ }),
3025+ }),
3026+ }),
3027+ After : cty .ObjectVal (map [string ]cty.Value {
3028+ "id" : cty .StringVal ("i-02ae66f368e8518a9" ),
3029+ "ami" : cty .StringVal ("ami-AFTER" ),
3030+ "disks" : cty .UnknownVal (cty .Set (cty .Object (map [string ]cty.Type {
3031+ "mount_point" : cty .String ,
3032+ "size" : cty .String ,
3033+ }))),
3034+ "root_block_device" : cty .SetVal ([]cty.Value {
3035+ cty .ObjectVal (map [string ]cty.Value {
3036+ "volume_type" : cty .StringVal ("gp2" ),
3037+ "new_field" : cty .StringVal ("new_value" ),
3038+ }),
3039+ }),
3040+ }),
3041+ RequiredReplace : cty .NewPathSet (),
3042+ Schema : testSchemaPlus (configschema .NestingSet ),
3043+ ExpectedOutput : ` # test_instance.example will be updated in-place
3044+ ~ resource "test_instance" "example" {
3045+ ~ ami = "ami-BEFORE" -> "ami-AFTER"
3046+ ~ disks = [
3047+ - {
3048+ - mount_point = "/var/diska" -> null
3049+ - size = "50GB" -> null
3050+ },
3051+ ] -> (known after apply)
3052+ id = "i-02ae66f368e8518a9"
3053+
3054+ # (1 unchanged block hidden)
3055+ }
29553056` ,
29563057 },
29573058 }
@@ -3288,6 +3389,115 @@ func TestResourceChange_nestedMap(t *testing.T) {
32883389 - volume_type = "gp2" -> null
32893390 }
32903391 }
3392+ ` ,
3393+ },
3394+ "in-place update - unknown" : {
3395+ Action : plans .Update ,
3396+ Mode : addrs .ManagedResourceMode ,
3397+ Before : cty .ObjectVal (map [string ]cty.Value {
3398+ "id" : cty .StringVal ("i-02ae66f368e8518a9" ),
3399+ "ami" : cty .StringVal ("ami-BEFORE" ),
3400+ "disks" : cty .MapVal (map [string ]cty.Value {
3401+ "disk_a" : cty .ObjectVal (map [string ]cty.Value {
3402+ "mount_point" : cty .StringVal ("/var/diska" ),
3403+ "size" : cty .StringVal ("50GB" ),
3404+ }),
3405+ }),
3406+ "root_block_device" : cty .MapVal (map [string ]cty.Value {
3407+ "a" : cty .ObjectVal (map [string ]cty.Value {
3408+ "volume_type" : cty .StringVal ("gp2" ),
3409+ "new_field" : cty .StringVal ("new_value" ),
3410+ }),
3411+ }),
3412+ }),
3413+ After : cty .ObjectVal (map [string ]cty.Value {
3414+ "id" : cty .StringVal ("i-02ae66f368e8518a9" ),
3415+ "ami" : cty .StringVal ("ami-AFTER" ),
3416+ "disks" : cty .UnknownVal (cty .Map (cty .Object (map [string ]cty.Type {
3417+ "mount_point" : cty .String ,
3418+ "size" : cty .String ,
3419+ }))),
3420+ "root_block_device" : cty .MapVal (map [string ]cty.Value {
3421+ "a" : cty .ObjectVal (map [string ]cty.Value {
3422+ "volume_type" : cty .StringVal ("gp2" ),
3423+ "new_field" : cty .StringVal ("new_value" ),
3424+ }),
3425+ }),
3426+ }),
3427+ RequiredReplace : cty .NewPathSet (),
3428+ Schema : testSchemaPlus (configschema .NestingMap ),
3429+ ExpectedOutput : ` # test_instance.example will be updated in-place
3430+ ~ resource "test_instance" "example" {
3431+ ~ ami = "ami-BEFORE" -> "ami-AFTER"
3432+ ~ disks = {
3433+ - "disk_a" = {
3434+ - mount_point = "/var/diska" -> null
3435+ - size = "50GB" -> null
3436+ },
3437+ } -> (known after apply)
3438+ id = "i-02ae66f368e8518a9"
3439+
3440+ # (1 unchanged block hidden)
3441+ }
3442+ ` ,
3443+ },
3444+ "in-place update - insertion sensitive" : {
3445+ Action : plans .Update ,
3446+ Mode : addrs .ManagedResourceMode ,
3447+ Before : cty .ObjectVal (map [string ]cty.Value {
3448+ "id" : cty .StringVal ("i-02ae66f368e8518a9" ),
3449+ "ami" : cty .StringVal ("ami-BEFORE" ),
3450+ "disks" : cty .MapValEmpty (cty .Object (map [string ]cty.Type {
3451+ "mount_point" : cty .String ,
3452+ "size" : cty .String ,
3453+ })),
3454+ "root_block_device" : cty .MapVal (map [string ]cty.Value {
3455+ "a" : cty .ObjectVal (map [string ]cty.Value {
3456+ "volume_type" : cty .StringVal ("gp2" ),
3457+ "new_field" : cty .StringVal ("new_value" ),
3458+ }),
3459+ }),
3460+ }),
3461+ After : cty .ObjectVal (map [string ]cty.Value {
3462+ "id" : cty .StringVal ("i-02ae66f368e8518a9" ),
3463+ "ami" : cty .StringVal ("ami-AFTER" ),
3464+ "disks" : cty .MapVal (map [string ]cty.Value {
3465+ "disk_a" : cty .ObjectVal (map [string ]cty.Value {
3466+ "mount_point" : cty .StringVal ("/var/diska" ),
3467+ "size" : cty .StringVal ("50GB" ),
3468+ }),
3469+ }),
3470+ "root_block_device" : cty .MapVal (map [string ]cty.Value {
3471+ "a" : cty .ObjectVal (map [string ]cty.Value {
3472+ "volume_type" : cty .StringVal ("gp2" ),
3473+ "new_field" : cty .StringVal ("new_value" ),
3474+ }),
3475+ }),
3476+ }),
3477+ AfterValMarks : []cty.PathValueMarks {
3478+ {
3479+ Path : cty.Path {cty.GetAttrStep {Name : "disks" },
3480+ cty.IndexStep {Key : cty .StringVal ("disk_a" )},
3481+ cty.GetAttrStep {Name : "mount_point" },
3482+ },
3483+ Marks : cty .NewValueMarks (marks .Sensitive ),
3484+ },
3485+ },
3486+ RequiredReplace : cty .NewPathSet (),
3487+ Schema : testSchemaPlus (configschema .NestingMap ),
3488+ ExpectedOutput : ` # test_instance.example will be updated in-place
3489+ ~ resource "test_instance" "example" {
3490+ ~ ami = "ami-BEFORE" -> "ami-AFTER"
3491+ ~ disks = {
3492+ + "disk_a" = {
3493+ + mount_point = (sensitive)
3494+ + size = "50GB"
3495+ },
3496+ }
3497+ id = "i-02ae66f368e8518a9"
3498+
3499+ # (1 unchanged block hidden)
3500+ }
32913501` ,
32923502 },
32933503 }
0 commit comments