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

HCP Terraform workspace plan fails with `No value for required variable` although the variable is set in the workspace.

AdvancedTroubleshootingModules, Variables, Sensitive Values and Workspaces
Answer

Likely causes → The variable was created as an Environment variable (without the TF_VAR_ prefix) instead of a Terraform variable; or it's set on a variable set not attached to this workspace/project; or the CLI-driven run uses a local -var-file that HCP doesn't read.

Diagnose → Check the workspace Variables page: category "terraform" vs "env", and attached variable sets.

Fix → Create it as a Terraform variable (or env var named TF_VAR_name), and attach the variable set to the workspace or project.

Prevent → Manage HCP variables and variable sets with the tfe provider.

All Terraform questions Roadmap: Terraform

More on Modules, Variables, Sensitive Values and Workspaces