@ -326,10 +326,6 @@ new line
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Computed : true } ,
"password" : { Type : cty . String , Optional : true , Sensitive : true } ,
// FIXME: This is a temporary situation; once the NestedType
// specific printer is implemented this will need to be
// updated so that only the sensitive nested attribute is
// hidden.
"conn_info" : {
NestedType : & configschema . Object {
Nesting : configschema . NestingSingle ,
@ -345,7 +341,10 @@ new line
Tainted : false ,
ExpectedOutput : ` # test_instance . example will be created
+ resource "test_instance" "example" {
+ conn_info = ( sensitive value )
+ conn_info = {
+ password = ( sensitive value )
+ user = "not-secret"
}
+ id = ( known after apply )
+ password = ( sensitive value )
}
@ -2251,7 +2250,7 @@ func TestResourceChange_nestedList(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : testSchemaNestingList ,
Schema : testSchema ( configschema . NestingList ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
@ -2280,8 +2279,8 @@ func TestResourceChange_nestedList(t *testing.T) {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-AFTER" ) ,
"disks" : cty . ListVal ( [ ] cty . Value { cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . NullVal( cty . String ) ,
"size" : cty . NullVal( cty . String ) ,
"mount_point" : cty . StringVal( "/var/diska" ) ,
"size" : cty . StringVal( "50GB" ) ,
} ) } ) ,
"root_block_device" : cty . ListVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
@ -2291,15 +2290,15 @@ func TestResourceChange_nestedList(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : testSchemaNestingList ,
Schema : testSchema ( configschema . NestingList ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [ ] - > [
+ {
+ mount_point = null
+ size = null
} ,
~ disks = [
~ {
+ mount_point = "/var/diska"
+ size = "50GB"
} ,
]
id = "i-02ae66f368e8518a9"
@ -2338,15 +2337,14 @@ func TestResourceChange_nestedList(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : testSchemaNestingList ,
Schema : testSchema ( configschema . NestingList ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [ ] - > [
+ {
+ mount_point = "/var/diska"
+ size = null
} ,
~ disks = [
~ {
+ mount_point = "/var/diska"
} ,
]
id = "i-02ae66f368e8518a9"
@ -2393,48 +2391,15 @@ func TestResourceChange_nestedList(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
"disks" : {
NestedType : & configschema . Object {
Attributes : map [ string ] * configschema . Attribute {
"mount_point" : { Type : cty . String , Optional : true } ,
"size" : { Type : cty . String , Optional : true } ,
} ,
Nesting : configschema . NestingList ,
} ,
} ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
"new_field" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingList ,
} ,
} ,
} ,
Schema : testSchemaPlus ( configschema . NestingList ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [
~ {
~ size = null - > "50GB"
# ( 1 unchanged element hidden )
} ,
+ size = "50GB"
# ( 1 unchanged attribute hidden )
} ,
]
id = "i-02ae66f368e8518a9"
@ -2484,11 +2449,6 @@ func TestResourceChange_nestedList(t *testing.T) {
cty . IndexStep { Key : cty . NumberIntVal ( 0 ) } ,
cty . GetAttrStep { Name : "volume_type" } ,
} ,
// FIXME: This is not currently used; when the diff printer is
// updated to fully handle NestedTypes this test should fail,
// and the expected output should look like this:
//
// ~ mount_point = "/var/diska" -> "/var/diskb" # forces replacement
cty . Path {
cty . GetAttrStep { Name : "disks" } ,
cty . IndexStep { Key : cty . NumberIntVal ( 0 ) } ,
@ -2496,15 +2456,15 @@ func TestResourceChange_nestedList(t *testing.T) {
} ,
) ,
Tainted : false ,
Schema : testSchemaNestingList ,
Schema : testSchema ( configschema . NestingList ) ,
ExpectedOutput : ` # test_instance . example must be replaced
- / + resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [
~ {
~ mount_point = "/var/diska" - > "/var/diskb"
# ( 1 unchanged element hidden )
} ,
~ mount_point = "/var/diska" - > "/var/diskb" # forces replacement
# ( 1 unchanged attribute hidden )
} ,
]
id = "i-02ae66f368e8518a9"
@ -2552,15 +2512,15 @@ func TestResourceChange_nestedList(t *testing.T) {
cty . Path { cty . GetAttrStep { Name : "disks" } } ,
) ,
Tainted : false ,
Schema : testSchemaNestingList ,
Schema : testSchema ( configschema . NestingList ) ,
ExpectedOutput : ` # test_instance . example must be replaced
- / + resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [ # forces replacement
~ {
~ mount_point = "/var/diska" - > "/var/diskb"
# ( 1 unchanged element hidden )
} # forces replacement ,
~ mount_point = "/var/diska" - > "/var/diskb"
# ( 1 unchanged attribute hidden )
} ,
]
id = "i-02ae66f368e8518a9"
@ -2601,16 +2561,16 @@ func TestResourceChange_nestedList(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : testSchemaNestingList ,
Schema : testSchema ( configschema . NestingList ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [
- {
- mount_point = "/var/diska"
- size = "50GB"
} ,
] - > [ ]
~ {
- mount_point = "/var/diska" - > null
- size = "50GB" - > null
} ,
]
id = "i-02ae66f368e8518a9"
- root_block_device {
@ -2658,6 +2618,49 @@ func TestResourceChange_nestedList(t *testing.T) {
+ attr = true
}
}
` ,
} ,
"in-place sequence update - deletion" : {
Action : plans . Update ,
Mode : addrs . ManagedResourceMode ,
Before : cty . ObjectVal ( map [ string ] cty . Value {
"list" : cty . ListVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value { "attr" : cty . StringVal ( "x" ) } ) ,
cty . ObjectVal ( map [ string ] cty . Value { "attr" : cty . StringVal ( "y" ) } ) ,
} ) ,
} ) ,
After : cty . ObjectVal ( map [ string ] cty . Value {
"list" : cty . ListVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value { "attr" : cty . StringVal ( "y" ) } ) ,
cty . ObjectVal ( map [ string ] cty . Value { "attr" : cty . StringVal ( "z" ) } ) ,
} ) ,
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
BlockTypes : map [ string ] * configschema . NestedBlock {
"list" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"attr" : {
Type : cty . String ,
Required : true ,
} ,
} ,
} ,
Nesting : configschema . NestingList ,
} ,
} ,
} ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ list {
~ attr = "x" - > "y"
}
~ list {
~ attr = "y" - > "z"
}
}
` ,
} ,
}
@ -2672,6 +2675,10 @@ func TestResourceChange_nestedSet(t *testing.T) {
Before : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-BEFORE" ) ,
"disks" : cty . SetValEmpty ( cty . Object ( map [ string ] cty . Type {
"mount_point" : cty . String ,
"size" : cty . String ,
} ) ) ,
"root_block_device" : cty . SetValEmpty ( cty . Object ( map [ string ] cty . Type {
"volume_type" : cty . String ,
} ) ) ,
@ -2679,6 +2686,12 @@ func TestResourceChange_nestedSet(t *testing.T) {
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-AFTER" ) ,
"disks" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . NullVal ( cty . String ) ,
} ) ,
} ) ,
"root_block_device" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -2687,30 +2700,16 @@ func TestResourceChange_nestedSet(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingSet ,
} ,
} ,
} ,
Schema : testSchema ( configschema . NestingSet ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [
+ {
+ mount_point = "/var/diska"
} ,
]
id = "i-02ae66f368e8518a9"
+ root_block_device {
+ volume_type = "gp2"
@ -2724,6 +2723,12 @@ func TestResourceChange_nestedSet(t *testing.T) {
Before : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-BEFORE" ) ,
"disks" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . NullVal ( cty . String ) ,
} ) ,
} ) ,
"root_block_device" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -2734,6 +2739,12 @@ func TestResourceChange_nestedSet(t *testing.T) {
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-AFTER" ) ,
"disks" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
"root_block_device" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -2743,35 +2754,20 @@ func TestResourceChange_nestedSet(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
"new_field" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingSet ,
} ,
} ,
} ,
Schema : testSchemaPlus ( configschema . NestingSet ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [
+ {
+ mount_point = "/var/diska"
+ size = "50GB"
} ,
- {
- mount_point = "/var/diska" - > null
} ,
]
id = "i-02ae66f368e8518a9"
+ root_block_device {
+ new_field = "new_value"
@ -2794,6 +2790,12 @@ func TestResourceChange_nestedSet(t *testing.T) {
"volume_type" : cty . StringVal ( "gp2" ) ,
} ) ,
} ) ,
"disks" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
} ) ,
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
@ -2803,35 +2805,33 @@ func TestResourceChange_nestedSet(t *testing.T) {
"volume_type" : cty . StringVal ( "different" ) ,
} ) ,
} ) ,
"disks" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diskb" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
} ) ,
RequiredReplace : cty . NewPathSet ( cty . Path {
cty . GetAttrStep { Name : "root_block_device" } ,
} ) ,
RequiredReplace : cty . NewPathSet (
cty . Path { cty . GetAttrStep { Name : "root_block_device" } } ,
cty . Path { cty . GetAttrStep { Name : "disks" } } ,
) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingSet ,
} ,
} ,
} ,
Schema : testSchema ( configschema . NestingSet ) ,
ExpectedOutput : ` # test_instance . example must be replaced
- / + resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [
- { # forces replacement
- mount_point = "/var/diska" - > null
- size = "50GB" - > null
} ,
+ { # forces replacement
+ mount_point = "/var/diskb"
+ size = "50GB"
} ,
]
id = "i-02ae66f368e8518a9"
+ root_block_device { # forces replacement
+ volume_type = "different"
@ -2854,6 +2854,12 @@ func TestResourceChange_nestedSet(t *testing.T) {
"new_field" : cty . StringVal ( "new_value" ) ,
} ) ,
} ) ,
"disks" : cty . SetVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
} ) ,
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
@ -2862,38 +2868,24 @@ func TestResourceChange_nestedSet(t *testing.T) {
"volume_type" : cty . String ,
"new_field" : cty . String ,
} ) ) ,
"disks" : cty . SetValEmpty ( cty . Object ( map [ string ] cty . Type {
"mount_point" : cty . String ,
"size" : cty . String ,
} ) ) ,
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
"new_field" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingSet ,
} ,
} ,
} ,
Schema : testSchemaPlus ( configschema . NestingSet ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = [
- {
- mount_point = "/var/diska" - > null
- size = "50GB" - > null
} ,
]
id = "i-02ae66f368e8518a9"
- root_block_device {
- new_field = "new_value" - > null
@ -2914,6 +2906,10 @@ func TestResourceChange_nestedMap(t *testing.T) {
Before : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-BEFORE" ) ,
"disks" : cty . MapValEmpty ( cty . Object ( map [ string ] cty . Type {
"mount_point" : cty . String ,
"size" : cty . String ,
} ) ) ,
"root_block_device" : cty . MapValEmpty ( cty . Object ( map [ string ] cty . Type {
"volume_type" : cty . String ,
} ) ) ,
@ -2921,6 +2917,12 @@ func TestResourceChange_nestedMap(t *testing.T) {
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-AFTER" ) ,
"disks" : cty . MapVal ( map [ string ] cty . Value {
"disk_a" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . NullVal ( cty . String ) ,
} ) ,
} ) ,
"root_block_device" : cty . MapVal ( map [ string ] cty . Value {
"a" : cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -2929,30 +2931,16 @@ func TestResourceChange_nestedMap(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingMap ,
} ,
} ,
} ,
Schema : testSchema ( configschema . NestingMap ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = {
+ "disk_a" = {
+ mount_point = "/var/diska"
} ,
}
id = "i-02ae66f368e8518a9"
+ root_block_device "a" {
+ volume_type = "gp2"
@ -2966,6 +2954,12 @@ func TestResourceChange_nestedMap(t *testing.T) {
Before : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-BEFORE" ) ,
"disks" : cty . MapVal ( map [ string ] cty . Value {
"disk_a" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . NullVal ( cty . String ) ,
} ) ,
} ) ,
"root_block_device" : cty . MapVal ( map [ string ] cty . Value {
"a" : cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -2976,6 +2970,12 @@ func TestResourceChange_nestedMap(t *testing.T) {
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-AFTER" ) ,
"disks" : cty . MapVal ( map [ string ] cty . Value {
"disk_a" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
"root_block_device" : cty . MapVal ( map [ string ] cty . Value {
"a" : cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -2985,35 +2985,17 @@ func TestResourceChange_nestedMap(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
"new_field" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingMap ,
} ,
} ,
} ,
Schema : testSchemaPlus ( configschema . NestingMap ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = {
~ "disk_a" = {
+ size = "50GB"
# ( 1 unchanged attribute hidden )
} ,
}
id = "i-02ae66f368e8518a9"
~ root_block_device "a" {
+ new_field = "new_value"
@ -3028,6 +3010,12 @@ func TestResourceChange_nestedMap(t *testing.T) {
Before : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-BEFORE" ) ,
"disks" : cty . MapVal ( map [ string ] cty . Value {
"disk_a" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
"root_block_device" : cty . MapVal ( map [ string ] cty . Value {
"a" : cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -3038,6 +3026,16 @@ func TestResourceChange_nestedMap(t *testing.T) {
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-AFTER" ) ,
"disks" : cty . MapVal ( map [ string ] cty . Value {
"disk_a" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
"disk_2" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/disk2" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
"root_block_device" : cty . MapVal ( map [ string ] cty . Value {
"a" : cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -3051,35 +3049,20 @@ func TestResourceChange_nestedMap(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
"new_field" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingMap ,
} ,
} ,
} ,
Schema : testSchemaPlus ( configschema . NestingMap ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = {
+ "disk_2" = {
+ mount_point = "/var/disk2"
+ size = "50GB"
} ,
"disk_a" = {
# ( 2 unchanged attributes hidden )
} ,
}
id = "i-02ae66f368e8518a9"
+ root_block_device "b" {
+ new_field = "new_value"
@ -3095,6 +3078,12 @@ func TestResourceChange_nestedMap(t *testing.T) {
Before : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-BEFORE" ) ,
"disks" : cty . MapVal ( map [ string ] cty . Value {
"disk_a" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
"root_block_device" : cty . MapVal ( map [ string ] cty . Value {
"a" : cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -3107,6 +3096,12 @@ func TestResourceChange_nestedMap(t *testing.T) {
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-AFTER" ) ,
"disks" : cty . MapVal ( map [ string ] cty . Value {
"disk_a" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "100GB" ) ,
} ) ,
} ) ,
"root_block_device" : cty . MapVal ( map [ string ] cty . Value {
"a" : cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "different" ) ,
@ -3119,32 +3114,21 @@ func TestResourceChange_nestedMap(t *testing.T) {
RequiredReplace : cty . NewPathSet ( cty . Path {
cty . GetAttrStep { Name : "root_block_device" } ,
cty . IndexStep { Key : cty . StringVal ( "a" ) } ,
} ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingMap ,
} ,
} ,
} ,
cty . Path { cty . GetAttrStep { Name : "disks" } } ,
) ,
Tainted : false ,
Schema : testSchema ( configschema . NestingMap ) ,
ExpectedOutput : ` # test_instance . example must be replaced
- / + resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = {
~ "disk_a" = { # forces replacement
~ size = "50GB" - > "100GB"
# ( 1 unchanged attribute hidden )
} ,
}
id = "i-02ae66f368e8518a9"
~ root_block_device "a" { # forces replacement
~ volume_type = "gp2" - > "different"
@ -3159,6 +3143,12 @@ func TestResourceChange_nestedMap(t *testing.T) {
Before : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-BEFORE" ) ,
"disks" : cty . MapVal ( map [ string ] cty . Value {
"disk_a" : cty . ObjectVal ( map [ string ] cty . Value {
"mount_point" : cty . StringVal ( "/var/diska" ) ,
"size" : cty . StringVal ( "50GB" ) ,
} ) ,
} ) ,
"root_block_device" : cty . MapVal ( map [ string ] cty . Value {
"a" : cty . ObjectVal ( map [ string ] cty . Value {
"volume_type" : cty . StringVal ( "gp2" ) ,
@ -3169,6 +3159,10 @@ func TestResourceChange_nestedMap(t *testing.T) {
After : cty . ObjectVal ( map [ string ] cty . Value {
"id" : cty . StringVal ( "i-02ae66f368e8518a9" ) ,
"ami" : cty . StringVal ( "ami-AFTER" ) ,
"disks" : cty . MapValEmpty ( cty . Object ( map [ string ] cty . Type {
"mount_point" : cty . String ,
"size" : cty . String ,
} ) ) ,
"root_block_device" : cty . MapValEmpty ( cty . Object ( map [ string ] cty . Type {
"volume_type" : cty . String ,
"new_field" : cty . String ,
@ -3176,84 +3170,23 @@ func TestResourceChange_nestedMap(t *testing.T) {
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
"new_field" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : configschema . NestingMap ,
} ,
} ,
} ,
Schema : testSchemaPlus ( configschema . NestingMap ) ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ ami = "ami-BEFORE" - > "ami-AFTER"
id = "i-02ae66f368e8518a9"
~ ami = "ami-BEFORE" - > "ami-AFTER"
~ disks = {
- "disk_a" = {
- mount_point = "/var/diska" - > null
- size = "50GB" - > null
} ,
}
id = "i-02ae66f368e8518a9"
- root_block_device "a" {
- new_field = "new_value" - > null
- volume_type = "gp2" - > null
}
}
` ,
} ,
"in-place sequence update - deletion" : {
Action : plans . Update ,
Mode : addrs . ManagedResourceMode ,
Before : cty . ObjectVal ( map [ string ] cty . Value {
"list" : cty . ListVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value { "attr" : cty . StringVal ( "x" ) } ) ,
cty . ObjectVal ( map [ string ] cty . Value { "attr" : cty . StringVal ( "y" ) } ) ,
} ) ,
} ) ,
After : cty . ObjectVal ( map [ string ] cty . Value {
"list" : cty . ListVal ( [ ] cty . Value {
cty . ObjectVal ( map [ string ] cty . Value { "attr" : cty . StringVal ( "y" ) } ) ,
cty . ObjectVal ( map [ string ] cty . Value { "attr" : cty . StringVal ( "z" ) } ) ,
} ) ,
} ) ,
RequiredReplace : cty . NewPathSet ( ) ,
Tainted : false ,
Schema : & configschema . Block {
BlockTypes : map [ string ] * configschema . NestedBlock {
"list" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"attr" : {
Type : cty . String ,
Required : true ,
} ,
} ,
} ,
Nesting : configschema . NestingList ,
} ,
} ,
} ,
ExpectedOutput : ` # test_instance . example will be updated in - place
~ resource "test_instance" "example" {
~ list {
~ attr = "x" - > "y"
}
~ list {
~ attr = "y" - > "z"
}
}
` ,
} ,
}
@ -4343,33 +4276,73 @@ func outputChange(name string, before, after cty.Value, sensitive bool) *plans.O
return changeSrc
}
// A basic test schema using NestingList for one attribute and one block
var testSchemaNestingList = & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
"disks" : {
NestedType : & configschema . Object {
Attributes : map [ string ] * configschema . Attribute {
"mount_point" : { Type : cty . String , Optional : true } ,
"size" : { Type : cty . String , Optional : true } ,
// A basic test schema using a configurable NestingMode for one (NestedType) attribute and one block
func testSchema ( nesting configschema . NestingMode ) * configschema . Block {
return & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
"disks" : {
NestedType : & configschema . Object {
Attributes : map [ string ] * configschema . Attribute {
"mount_point" : { Type : cty . String , Optional : true } ,
"size" : { Type : cty . String , Optional : true } ,
} ,
Nesting : nesting ,
} ,
Nesting : configschema . NestingList ,
} ,
} ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : nesting ,
} ,
Nesting : configschema . NestingList ,
} ,
} ,
}
}
// similar to testSchema with the addition of a "new_field" block
func testSchemaPlus ( nesting configschema . NestingMode ) * configschema . Block {
return & configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"id" : { Type : cty . String , Optional : true , Computed : true } ,
"ami" : { Type : cty . String , Optional : true } ,
"disks" : {
NestedType : & configschema . Object {
Attributes : map [ string ] * configschema . Attribute {
"mount_point" : { Type : cty . String , Optional : true } ,
"size" : { Type : cty . String , Optional : true } ,
} ,
Nesting : nesting ,
} ,
} ,
} ,
BlockTypes : map [ string ] * configschema . NestedBlock {
"root_block_device" : {
Block : configschema . Block {
Attributes : map [ string ] * configschema . Attribute {
"volume_type" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
"new_field" : {
Type : cty . String ,
Optional : true ,
Computed : true ,
} ,
} ,
} ,
Nesting : nesting ,
} ,
} ,
}
}