forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
command/jsonstate: fix inconsistency with resource address (hashicorp…
…#24256) * command/jsonstate: fix inconsistency with resource address Resource addresses in state output were not including index for instances created with for_each or count, while the index was appearing in the plan output. This PR fixes that inconsistency, adds tests, and updates the existing tests. Fixes hashicorp#24110 * add tests showing expected prior state resource addressing * added example of show json state output with modules
- Loading branch information
1 parent
1305ea3
commit 2ddea68
Showing
13 changed files
with
508 additions
and
17 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
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,11 @@ | ||
variable "test_var" { | ||
default = "bar-var" | ||
} | ||
|
||
output "test" { | ||
value = var.test_var | ||
} | ||
|
||
resource "test_instance" "test" { | ||
ami = var.test_var | ||
} |
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,14 @@ | ||
variable "test_var" { | ||
default = "foo-var" | ||
} | ||
|
||
resource "test_instance" "test" { | ||
ami = var.test_var | ||
count = 1 | ||
} | ||
|
||
output "test" { | ||
value = var.test_var | ||
} | ||
|
||
provider "test" {} |
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 @@ | ||
module "module_test_foo" { | ||
source = "./foo" | ||
test_var = "baz" | ||
} | ||
|
||
module "module_test_bar" { | ||
source = "./bar" | ||
} | ||
|
||
output "test" { | ||
value = module.module_test_foo.test | ||
depends_on = [module.module_test_foo] | ||
} |
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,51 @@ | ||
{ | ||
"format_version": "0.1", | ||
"terraform_version": "0.12.0", | ||
"values": { | ||
"outputs": { | ||
"test": { | ||
"sensitive": false, | ||
"value": "baz" | ||
} | ||
}, | ||
"root_module": { | ||
"child_modules": [ | ||
{ | ||
"resources": [ | ||
{ | ||
"address": "module.module_test_foo.test_instance.example[0]", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "example", | ||
"index": 0, | ||
"provider_name": "test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": "foo-var", | ||
"id": null | ||
} | ||
} | ||
], | ||
"address": "module.module_test_foo" | ||
}, | ||
{ | ||
"resources": [ | ||
{ | ||
"address": "module.module_test_bar.test_instance.example", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "example", | ||
"provider_name": "test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": "bar-var", | ||
"id": null | ||
} | ||
} | ||
], | ||
"address": "module.module_test_bar" | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.