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

`Error: No value for required variable` — `The root module input variable "db_password" is not set, and has no default value.` in CI.

BeginnerTroubleshootingModules, Variables, Sensitive Values and Workspaces
Answer

Likely causes → The local terraform.tfvars (gitignored) or your shell's TF_VAR_db_password isn't present in CI.

Diagnose → env | grep TF_VAR_ in the job (masked); check which -var-file is passed.

Fix → Provide it from the CI secret store as TF_VAR_db_password, or better, read the secret inside Terraform from Secrets Manager (or use an ephemeral resource/write-only argument where supported).

Prevent → Commit non-secret env/*.tfvars; keep secrets out of variables entirely where possible.

All Terraform questions Roadmap: Terraform

More on Modules, Variables, Sensitive Values and Workspaces