A file with a comment
The values convert and the comment cannot, so it is quoted back before it is lost
# Raised for TICKET-4821, do not lower without asking. instance_count = 12 region = "eu-west-1"
Convert .tfvars to terraform.tfvars.json. Two things go wrong in a migration like this: the comments cannot come across, and both files are loaded if you leave both.
Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.
The answer appears here
Paste on the left and press Convert. Nothing leaves this tab.
Nothing else to flag.
No formatting problems, and nothing the rules object to. Worth remembering what that covers: this reads the file you pasted, not the account or cluster it will be applied to.
No finding matches that filter.
Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.
The values convert and the comment cannot, so it is quoted back before it is lost
# Raised for TICKET-4821, do not lower without asking. instance_count = 12 region = "eu-west-1"
Already invalid: there is no expression language while a tfvars file is read
region = var.region
Converting changes the filename, and a .gitignore rule for *.tfvars will not match the new one
db_password = "REPLACE_ME" region = "eu-west-1"
These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.
The JSON is loaded second, so it wins for every name it defines and the HCL still applies for the rest. Both files look right on their own.
Instead:Delete the .tfvars file in the same commit that adds the .tfvars.json.
JSON has no comments, and a tfvars comment is usually the only record of why a value is what it is.
Instead:Move the reasoning into the variable descriptions in variables.tf first, then convert.
A pattern for *.tfvars does not match *.tfvars.json, so a file that was ignored becomes committable.
Instead:Add *.tfvars.json alongside *.tfvars.
Leaving both in place during a conversion means half the values come from each file, silently, with nothing to say which is which.
The JSON overrides the HCL for every name it defines and leaves the HCL in force for every name it does not. So a partially converted file produces a configuration nobody wrote, and both files look correct on their own.
terraform.tfvars.json, and anything matching *.auto.tfvars.json. Any other name, prod.tfvars.json included, needs -var-file on every command. That is useful for per-environment files and a surprise for anybody who renamed the default file to something tidier.
There are no variables, no locals and no functions available while it is read. A reference in a tfvars file is already invalid rather than something the conversion loses, so this page refuses those lines rather than guessing at them.
Correct and unreadable: every newline becomes an escape on a single line, which ends any hope of reviewing an IAM policy or a startup script in a diff. An indented heredoc also had its indentation stripped during parsing, and that is not recoverable. Consider moving the document to its own file and reading it with file() instead.
A rule for *.tfvars does not match *.tfvars.json. A file that was safely ignored becomes a file that is not, and the values in it did not get less sensitive by changing format.
Comments cannot come across, and they are usually the only record of why
JSON has no comment syntax. A comment in a tfvars file is nearly always the note explaining which ticket raised a limit, which account an id belongs to, or what breaks if it changes. Move that reasoning into the variable descriptions in variables.tf before converting, which is a better home for it anyway.