Interview Prep/Terraform/Lost, Corrupted and Drifted State

A new engineer's `terraform plan` shows 50 changes, while CI shows none for the same commit.

IntermediateTroubleshootingLost, Corrupted and Drifted State
Answer

Likely causes → Different workspace, different var files or TF_VAR_* environment variables, a different provider version (old .terraform dir with an unlocked provider), or different credentials pointing at another account.

Diagnose →

terraform workspace show; env | grep ^TF_; aws sts get-caller-identity
terraform version; cat .terraform.lock.hcl | grep -A1 'provider "registry'

Fix → Align workspace, var files and credentials; rm -rf .terraform && terraform init.

Prevent → Wrap commands in a Makefile/script that selects workspace and var file, and print account ID and workspace at the top.

All Terraform questions Roadmap: Terraform in production

More on Lost, Corrupted and Drifted State