'Is it risky to have trailing commas in .tfvars or auto.tfvars files?
I see that the official Terraform documentation shows that trailing commas in arrays are okay in .tfvars files. Their example:
availability_zone_names = [
"us-east-1a",
"us-west-1c",
]
However, .tfvars.json files get parsed as JSON so I assume they wouldn't allow this. Therefore, is it bad practice to have trailing commmas in a .tfvars or .auto.tfvars file? Is there any scenario where an auto.tfvars file would somehow need to be converted into a .tfvars.json file behind the scenes (or explicitely) and this could cause problems?
Solution 1:[1]
Therefore, is it bad practice to have trailing commmas in a .tfvars or .auto.tfvars file?
No per se as it won't affect anything, but an extra character is an extra character that could have not been there in the first place.
Is there any scenario where an
auto.tfvarsfile would somehow need to be converted into a.tfvars.jsonfile behind the scenes (or explicitly) and this could cause problems?
Not that I'm aware of, but even if so I would assume for Terraform to have its own sanitisation measures in place if they are doing conversions or for it to fail fast & early.
All in all, It's not risky to have trailing commas in .tfvars or auto.tfvars files.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ermiya Eskandary |
