An internal service generates the variable values for each deployment as a JSON object whose top-level keys are variable names. The team wants Terraform to load the file automatically on every plan in the root module, with no command-line options added. How should the generated file be named?
Select an answer to reveal the explanation.
Short Explanation
Terraform's file picker is picky about names: it wants .auto.tfvars.json for JSON it should grab on its own. The .json ending is what tells it to parse JSON, and the .auto part is what makes it automatic. Miss either piece and your values quietly don't show up.
Full Explanation
Terraform automatically loads variable definition files named terraform.tfvars or terraform.tfvars.json and files whose names end in .auto.tfvars or .auto.tfvars.json. When a file name ends in .json, Terraform parses it as a JSON object whose root keys are variable names. Naming the generated file generated.auto.tfvars.json therefore makes it load on every plan and be parsed correctly, with the same precedence as other auto files, processed in lexical order. A name such as generated.tfvars.json is valid only as an explicit -var-file argument; apart from terraform.tfvars.json, files without the .auto suffix are not loaded automatically. generated.auto.json matches no recognised pattern and is ignored. A file ending in .auto.tfvars is loaded automatically but parsed as native HCL syntax; Terraform chooses the parser from the extension, not by sniffing content, so a JSON object there would fail or be misread. Exam caveat: if the generator also writes keys that the configuration does not declare, Terraform warns about undeclared variables rather than failing. Operational check: run terraform plan with no options and confirm the generated values appear, or use terraform console to evaluate one of the variables.