-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing of maps in JSON variable files is broken. #15549
Comments
As far as I can tell this is a more widespread bug regarding maps in JSON files. While the documentation claims that JSON and HCL are interchangeable, as far as maps are concerned, this appears to not be the case. My use case is managing Amazon ECR (docker image for ECS) repositories. You need to define an ECR Repository for every image, so this becomes really cumbersome to maintain manually... so I'm trying to generate the terraform config from an external datasource. I'm seeing this same bug, but with a map in an
{
"resource": {
"aws_ecr_repository": {
"jantman_private-docker-redirector": {
"name": "jantman/private-docker-redirector"
}
}
},
"output": {
"ecr_jantman_private-docker-redirector": {
"value": {
"arn": "${aws_ecr_repository.jantman_private-docker-redirector.arn}",
"name": "${aws_ecr_repository.jantman_private-docker-redirector.name}",
"registry_id": "${aws_ecr_repository.jantman_private-docker-redirector.registry_id}",
"url": "${aws_ecr_repository.jantman_private-docker-redirector.url}"
}
}
}
} fails with:
But resource "aws_ecr_repository" "jantman_private-docker-redirector" {
name = "jantman/private-docker-redirector"
}
output "ecr_jantman_private-docker-redirector" {
value = {
"arn" = "${aws_ecr_repository.jantman_private-docker-redirector.arn}",
"name" = "${aws_ecr_repository.jantman_private-docker-redirector.name}",
"registry_id" = "${aws_ecr_repository.jantman_private-docker-redirector.registry_id}",
"url" = "${aws_ecr_repository.jantman_private-docker-redirector.url}"
}
} works fine. |
I understand that this is an open bug, however may I suggest at least updating these docs? The following statement is particularly misleading |
Hi all! Sorry for the weird behavior and the long silence here. This seems to be the same as #9555, which I closed today after verifying that it is fixed in Terraform v0.12.0-alpha1. I posted some more details in a comment in the other issue. The fix will also be included in the final v0.12.0 release. Thanks for reporting the issue, and sorry again for the slow response. |
as pointed out here: #9239 (comment) test_map in json has to be defined:
for my use case this wokrs like a charm. |
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
When declaring a map in JSON format in a Terraform variable file, it produces the error:
This looks to be a specific issue for the JSON format. Maps appear to work correctly for the HCL format, but is broken when using JSON.
Terraform Version
Terraform 0.9.11
Terraform Configuration Files
main.tf
hcl.tfvars
json.tfvars
Debug Output
https://gist.github.com/dbeckham/6a85d7c0fdbaed19521ff59ffb12b387
Expected Behavior
The JSON format should be treated exactly the same as HCL, and both test HCL and JSON test files should be treated the same.
Actual Behavior
Terraform produced the error:
Steps to Reproduce
Take the three files above and run the following commands:
If you run Terraform using the HCL file agove, you get the normal output telling you:
If you run the same command using the JSON version, you get the error:
The text was updated successfully, but these errors were encountered: