A root module directory contains terraform.tfvars setting instance_type = "t3.small" and prod.auto.tfvars setting instance_type = "m6i.large". A pipeline runs terraform plan with no -var or -var-file options and no TF_VAR_ environment variables. Which value does the plan use?
Select an answer to reveal the explanation.
Short Explanation
Think of it as a stack of sticky notes where the note on top wins, and you can predict the result every time. Terraform puts terraform.tfvars at the bottom and the *.auto.tfvars files above it, so the auto file's value shows through. The lexical-order trap only applies among the auto files themselves.
Full Explanation
Terraform loads variable definition files automatically when they are named terraform.tfvars, terraform.tfvars.json, or end in .auto.tfvars or .auto.tfvars.json. When the same root variable receives values from several sources, the documented precedence puts any .auto.tfvars or .auto.tfvars.json files, processed in lexical order, above terraform.tfvars.json, which is above terraform.tfvars, which is above TF_VAR_ environment variables and the declared default. With no command-line values, the value from prod.auto.tfvars therefore wins and the plan uses m6i.large. Treating terraform.tfvars as the primary, overriding file reverses the documented order; it is the lowest of the automatically loaded files. Terraform does not error when different files assign the same variable; reassigning a variable is forbidden only within a single file. Lexical ordering decides which of several auto files wins against each other, not whether an auto file beats terraform.tfvars. Exam caveat: in HCP Terraform, workspace variables and variable sets override both kinds of files. Operational check: run terraform console in the directory and evaluate var.instance_type, or remove prod.auto.tfvars temporarily and confirm the value falls back to t3.small.