Interview Prep/Terraform/Modules, Variables, Sensitive Values and Workspaces

`Warning: Value for undeclared variable` — `The root module does not declare a variable named "regoin" but a value was found in file "terraform.tfvars".` and the region silently defaults.

IntermediateTroubleshootingModules, Variables, Sensitive Values and Workspaces
Answer

Likely causes → Typo in tfvars; Terraform only warns for undeclared vars in files (it errors for -var on the CLI). The real variable keeps its default.

Diagnose → Read warnings, not just errors; terraform console → var.region.

Fix → Fix the typo. Consider removing defaults for important variables so a missing value fails.

Prevent → Fail CI on warnings for undeclared variables (grep the plan output), and use tflint rules.

All Terraform questions Roadmap: Terraform

More on Modules, Variables, Sensitive Values and Workspaces