-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
terraform --var-file "vars.json" will only read first submap in a nested map. #9239
Comments
Just an update, but this will now print an error in this case:
Because of the internal structure of HCL, the "correct" format for the JSON is actually:
Not this isn't very intuitive, and we usually do try to accept the more condensed JSON as input, so I'll keep this open to try and fix that issue (as well as the less than helpful error message we now get). |
list of objects won't work, either. I assume it's the same issue.
json file
expected
Actual
|
Sorry, I missed that you had a list type rather than a map. I think this is another edge case without a workaround at the moment. Fixing JSON input is something we're going to be working on soon. |
@jbardin can you provide a working example for 2 or more variables declared in a json I can get terraform to accept one json var value in a -var-file. It's when I ask terraform to accept 2 (or more) variable declarations in a -var-file (v0.8.4),
I'm wondering if it's my json formatting or? |
Hi all, I just verified this in v0.12.0-alpha2 using the same files as given (with the minor adjustment of specifying a more precise type (`map(map(string))`` for the variable to work around #19141):
The fix here comes from the switch to the new JSON parser implementation that is also now used for Sorry for the weird behavior, and for the long delay in getting it fixed. |
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. |
Terraform Version
0.7.4
Affected Resource(s)
maps and var files.
Terraform Configuration Files
main.tf:
vars.json:
Expected Behavior
Terraform should have merged the map from main.tf with the map and all of it's submaps declared in vars.json.
Actual Behavior
Terraform merges only the first submap from vars.json (map.regiona) and ignores any other maps (map.regionb, map.regionc). The first submap depends on the order they are declared in vars.json.
Note that regiona was successfully overwritten, the change to regionb was not made, and regionc is completely missing.
Steps to Reproduce
terraform apply -var-file vars.json
outputs the following:Important Factoids
Nested maps work fine if declared in hcl, ie if regionc is moved from
vars.json
tomain.tf
this would work and is our current workaround.The text was updated successfully, but these errors were encountered: