Terraform "Saved plan is stale" - Plan No Longer Matches State in CI
You saved a plan in one job and applied it in another, but the state changed in between. Terraform rejects the saved plan because applying it would no longer be safe.
What this error means
terraform apply tfplan in a separate job fails saying the saved plan is stale - the state has a different serial than when the plan was created. It happens when another run (or a manual change) touched state between plan and apply.
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.Common causes
State changed between plan and apply
Another apply, a drift, or a manual edit advanced the state serial after the plan file was written, so the saved plan no longer matches reality.
Long gap or no serialization between jobs
A manual approval gate or unserialized pipelines let another run modify state during the wait, invalidating the saved plan.
How to fix it
Re-plan and apply against current state
Generate a fresh plan immediately before applying so it matches the current state.
terraform plan -input=false -out=tfplan
terraform apply -input=false tfplanSerialize plan and apply
Use a CI concurrency group so no other run mutates state between the plan and apply jobs.
concurrency:
group: terraform-${{ github.ref }}
cancel-in-progress: falseHow to prevent it
- Keep the gap between plan and apply short, and re-plan if it grows.
- Serialize Terraform runs with a concurrency group.
- Treat a stale-plan error as a signal to re-plan, never to bypass.