Home / Tutorials / Terraform

Terraform · Infrastructure as code · Deploy blocked

Fix: Saved plan is stale

Error Error: Saved plan is stale

By the Erzon engineering team · A step-by-step fix, not a forum thread

This error means the saved plan file you tried to apply no longer matches the current state, so Terraform refuses to use it. A saved plan produced with terraform plan -out=tfplan records the exact state Terraform saw at plan time, and applying it is only safe if nothing has changed since. When state moves in the gap between planning and applying, the saved plan is stale, and Terraform will not act on stale assumptions. This is most common in CI, where plan and apply are separate stages with time and activity in between.

Error: Saved plan is stale

The given plan file can no longer be applied because the state was changed
by another operation after the plan was created.

What this error means

A saved plan is a snapshot of a decision: given this exact state, do these exact actions. Terraform stores a reference to the state it planned against inside the plan file. At apply time it checks that the current state still matches. If another operation changed state after the plan was created, the snapshot is out of date, and applying it could make changes based on resources that no longer look the way the plan assumed. Terraform declares the plan stale and stops. There is no force flag, on purpose, because the safe action is always to re-plan.

Common causes

  • A CI pipeline that plans in one stage and applies in a later stage, with state changing in between.
  • Another pipeline or a teammate applying to the same state during the gap.
  • A manual terraform apply or hotfix run between the plan and the apply.
  • Drift correction or a refresh that updated state after the plan was saved.
  • Reusing an old tfplan file from an earlier run rather than generating a fresh one.

How to fix it

Stabilize

  1. Do not try to force the old plan. Discard the stale tfplan file and regenerate against current state. First confirm what the current state actually shows.
terraform plan

Diagnose

  1. Figure out what changed state in the gap. Check whether another pipeline ran, whether someone applied manually, or whether a refresh updated state, so the same staleness does not recur next run.

  2. Confirm you are not accidentally reusing an old plan file from a previous run or a cached artifact.

Fix

Regenerate the plan against current state and apply that fresh file. Never reuse a plan file across a state change.

terraform plan -out=tfplan
terraform apply tfplan

In a CI pipeline, generate the plan and apply it as close together as possible, and pass the plan file through as an artifact so the apply stage uses the plan that was just made rather than an old one. If a manual approval sits between the stages, re-plan after approval rather than applying a plan that was made before the wait:

terraform apply -auto-approve tfplan

If applies to this state can happen from more than one place, serialize them with the state lock or a pipeline queue so nothing changes state between your plan and your apply.

How to prevent it

  • Keep the plan and apply stages close in time, and pass the plan file as a pipeline artifact so apply uses exactly that plan.
  • Serialize applies to each state with locking or a queue, so no other run changes state in the gap.
  • Re-plan after any manual approval delay rather than applying a plan made before the wait.
  • Never reuse a saved plan file across runs or after any state change.
  • Avoid out of band manual applies to state that a pipeline manages, since they invalidate in flight plans.

When to call a senior engineer

If plans go stale on nearly every run, if you cannot tell what keeps changing state between plan and apply, or if multiple pipelines and people are all applying to the same state and stepping on each other, the problem is your delivery workflow, not one plan file. Left alone it leads to race conditions and risky forced applies. Erzon engineers can restructure your plan and apply pipeline, add proper locking and serialization, and make your Terraform deploys deterministic so a saved plan applies cleanly every time.

Related errors we fix

Still down after this?

Want a senior engineer to just fix it?

Paste this exact error into the form. A senior engineer replies within one business hour with what is likely wrong and a flat quote. Triage is free.

Book a fix

← Back to all error fixes

Still down?

Get a senior engineer on it now

Leave your email and a line about what is happening. A senior engineer replies within one business hour with what is likely wrong and a flat quote. Triage is free.

Or email [email protected]. Same engineers, same one-hour clock.