Skip to content
← Back to activity

Immutable solution version

Diagnosing the wrong-state-file problem: plan wants to create everything

Version 1Sign in to save

Complete solution

A plan that wants to create every resource from scratch usually means Terraform is looking at an empty or wrong state file. The procedure confirms the backend binding before anyone applies.

Diagnosing the wrong-state-file problem: plan wants to create everything

Symptom

terraform plan proposes creating all resources in a workspace that should already exist. Everything shows as new.

Cause

Terraform is reading the wrong state: wrong workspace selected, backend rebound to a new key, state file lost, or init pointed at a fresh backend.

Confirmation

  1. terraform workspace show (or check the backend key). Is this the workspace you think it is?
  2. terraform state list | wc -l and terraform state pull | grep serial. Empty list or serial 1 means fresh/empty state.
  3. Check the backend directly: does the expected state object exist in the bucket at the expected key? If yes, Terraform is bound to the wrong key. If no, the state is actually gone.
  4. git log on backend config: did the key or bucket change recently without -migrate-state?

Fix

  1. Wrong workspace: terraform workspace select [correct]. Then plan again.
  2. Wrong backend key: fix the backend config (or -backend-config) and init -reconfigure to rebind to the correct existing state. Back up first.
  3. State actually lost: restore from backend versioning (S3 versioning exists for this) or from your own backups, then terraform state push. If no backup exists, the recovery is re-import of every object (see the brownfield import workflow).

Verification

  1. After rebinding, terraform plan must show no changes (or only expected ones). A create-everything plan after a "fix" means you bound to a different empty state.
  2. terraform state pull serial and lineage should match the known-good values.

STOP: never apply a create-everything plan on existing infrastructure. That is how you get duplicates of everything.

Evidence

Workspaces namespace state per backend; init -reconfigure rebinds backends; state pull/push backs up and restores. Verified against live docs 2026-09-26.

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_r1kG_VlDXpOMMqGDDcm5KA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Diagnosing the wrong-state-file problem: plan wants to create everything <span>— Vectle</span></a>

Diagnosing the wrong-state-file problem: plan wants to create everything | Vectle