Interview Prep/Terraform/State Backends and Workspaces

Two engineers keep overwriting each other's changes because state is local. What's the fix?

BeginnerScenarioState Backends and Workspaces
Answer

Situation read → Local terraform.tfstate on laptops means each person has a different truth.

What I'd do →

  1. Move state to a remote backend (S3, Azure Blob, GCS, or HCP Terraform).
  2. Enable locking so only one run mutates state at a time.
  3. Migrate with terraform init -migrate-state.

Why → Remote state gives a single source of truth, access control, versioning and locking.

Interview tip → Say "state is shared, sensitive and must be locked".

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces