Interview Prep/Terraform/State Backends and Workspaces

State is 40 MB and operations are slow. What do you do?

IntermediateScenarioState Backends and Workspaces
Answer

Situation read → Large state means slow refresh, slow locking and a large blast radius.

What I'd do →

  1. Identify heavy resource types with terraform state list | cut -d. -f1-2 | sort | uniq -c | sort -rn.
  2. Split by lifecycle into multiple states.
  3. Remove noisy resources such as thousands of IAM policy attachments from a hot path by moving them to their own stack.
  4. Use -refresh=false only for local iteration.

Why → Plan time scales with resource count; smaller states are faster and safer.

Interview tip → Splitting is a design fix, flags are a patch.

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces