A root module contains terraform.tfvars with dev values and prod.tfvars with prod values. A manual production apply was run without -var-file, silently loaded the dev values, and resized production resources. Which change best prevents this from happening again?
Select an answer to reveal the explanation.
Short Explanation
The problem isn't that prod.tfvars was wrong; it's that terraform.tfvars loads itself whether you asked for it or not. Make every environment's values opt-in and explicit, and a forgotten flag becomes a loud error instead of a quiet mistake.
Full Explanation
Terraform automatically loads terraform.tfvars, terraform.tfvars.json and any .auto.tfvars or .auto.tfvars.json files in the root module. Files with other names, such as dev.tfvars and prod.tfvars, load only when passed with -var-file. Keeping dev values in terraform.tfvars therefore makes dev the silent default for every run, including production runs where someone forgets the flag. Removing the auto-loaded file and having each environment's pipeline pass its own file with -var-file makes the selection explicit, and with required variables lacking defaults plus -input=false, a run without the file fails instead of applying the wrong values. Renaming the prod file to load automatically would load it in every environment, so dev runs would pick up prod values. TF_VAR_ environment variables have the lowest precedence, so they do not stop terraform.tfvars from loading, and a forgotten flag still yields dev values. Production defaults simply move the risk: a dev run without its file would then apply production sizing. Exam caveat: in HCP Terraform, workspace-scoped variables remove the need to choose files at run time. Operational check: run a plan without -var-file and confirm it fails on missing required variables.