-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests showing expected prior state resource addressing
- Loading branch information
1 parent
cf0de77
commit 095bf22
Showing
6 changed files
with
274 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"format_version": "0.1", | ||
"terraform_version": "0.12.0", | ||
"values": { | ||
"root_module": { | ||
"resources": [ | ||
{ | ||
"address": "test_instance.example[0]", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "example", | ||
"index": 0, | ||
"provider_name": "test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": null, | ||
"id": "621124146446964903" | ||
} | ||
}, | ||
{ | ||
"address": "test_instance.example[1]", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "example", | ||
"index": 1, | ||
"provider_name": "test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": null, | ||
"id": "4330206298367988603" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"version": 4, | ||
"terraform_version": "0.12.0", | ||
"serial": 1, | ||
"lineage": "00bfda35-ad61-ec8d-c013-14b0320bc416", | ||
"outputs": {}, | ||
"resources": [ | ||
{ | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "example", | ||
"each": "list", | ||
"provider": "provider.test", | ||
"instances": [ | ||
{ | ||
"index_key": 0, | ||
"schema_version": 0, | ||
"attributes": { | ||
"id": "621124146446964903" | ||
}, | ||
"private": "bnVsbA==" | ||
}, | ||
{ | ||
"index_key": 1, | ||
"schema_version": 0, | ||
"attributes": { | ||
"id": "4330206298367988603" | ||
}, | ||
"private": "bnVsbA==" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
variable "test_var" { | ||
default = "bar" | ||
} | ||
|
||
// There is a single instance in state. The plan will add a resource. | ||
resource "test_instance" "test" { | ||
ami = var.test_var | ||
count = 2 | ||
} | ||
|
||
output "test" { | ||
value = var.test_var | ||
} |
167 changes: 167 additions & 0 deletions
167
command/testdata/show-json/multi-resource-update/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
{ | ||
"format_version": "0.1", | ||
"terraform_version": "0.13.0", | ||
"variables": { | ||
"test_var": { | ||
"value": "bar" | ||
} | ||
}, | ||
"planned_values": { | ||
"outputs": { | ||
"test": { | ||
"sensitive": false, | ||
"value": "bar" | ||
} | ||
}, | ||
"root_module": { | ||
"resources": [ | ||
{ | ||
"address": "test_instance.test[0]", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test", | ||
"index": 0, | ||
"provider_name": "test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": "bar", | ||
"id": "placeholder" | ||
} | ||
}, | ||
{ | ||
"address": "test_instance.test[1]", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test", | ||
"index": 1, | ||
"provider_name": "test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": "bar" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"resource_changes": [ | ||
{ | ||
"address": "test_instance.test[0]", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test", | ||
"index": 0, | ||
"provider_name": "test", | ||
"change": { | ||
"actions": [ | ||
"no-op" | ||
], | ||
"before": { | ||
"ami": "bar", | ||
"id": "placeholder" | ||
}, | ||
"after": { | ||
"ami": "bar", | ||
"id": "placeholder" | ||
}, | ||
"after_unknown": {} | ||
} | ||
}, | ||
{ | ||
"address": "test_instance.test[1]", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test", | ||
"index": 1, | ||
"provider_name": "test", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"ami": "bar" | ||
}, | ||
"after_unknown": { | ||
"id": true | ||
} | ||
} | ||
} | ||
], | ||
"output_changes": { | ||
"test": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": "bar", | ||
"after_unknown": false | ||
} | ||
}, | ||
"prior_state": { | ||
"format_version": "0.1", | ||
"terraform_version": "0.13.0", | ||
"values": { | ||
"outputs": { | ||
"test": { | ||
"sensitive": false, | ||
"value": "bar" | ||
} | ||
}, | ||
"root_module": { | ||
"resources": [ | ||
{ | ||
"address": "test_instance.test[0]", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test", | ||
"index": 0, | ||
"provider_name": "test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": "bar", | ||
"id": "placeholder" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"configuration": { | ||
"root_module": { | ||
"outputs": { | ||
"test": { | ||
"expression": { | ||
"references": [ | ||
"var.test_var" | ||
] | ||
} | ||
} | ||
}, | ||
"resources": [ | ||
{ | ||
"address": "test_instance.test", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test", | ||
"provider_config_key": "test", | ||
"expressions": { | ||
"ami": { | ||
"references": [ | ||
"var.test_var" | ||
] | ||
} | ||
}, | ||
"schema_version": 0, | ||
"count_expression": { | ||
"constant_value": 2 | ||
} | ||
} | ||
], | ||
"variables": { | ||
"test_var": { | ||
"default": "bar" | ||
} | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
command/testdata/show-json/multi-resource-update/terraform.tfstate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"version": 4, | ||
"terraform_version": "0.12.0", | ||
"serial": 7, | ||
"lineage": "configuredUnchanged", | ||
"outputs": {}, | ||
"resources": [ | ||
{ | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test", | ||
"provider": "provider[\"registry.terraform.io/-/test\"]", | ||
"instances": [ | ||
{ | ||
"schema_version": 0, | ||
"attributes": { | ||
"ami": "bar", | ||
"id": "placeholder" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |