Terraform "Saved plan is stale" - Fix plan/apply Drift in CI
You applied a saved plan file, but the state changed since that plan was created. Terraform refuses to apply a plan built against an older state to avoid acting on stale assumptions.
What this error means
terraform apply tfplan fails saying the saved plan is stale or no longer valid, typically because another run modified state between the plan and apply jobs of a pipeline.
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
In a split plan/apply pipeline, another apply (or a drift) modified state after the plan file was written, invalidating it.
Concurrent runs racing the same state
Two pipelines plan and apply against the same state without serialization, so one’s apply lands on state the other already moved.
How to fix it
Re-plan immediately before apply
Regenerate the plan in the same job (or right before apply) so it matches current state.
terraform plan -input=false -out=tfplan
terraform apply -input=false tfplanSerialize Terraform runs
Prevent concurrent applies against the same state with a CI concurrency group so a saved plan cannot be raced.
concurrency:
group: terraform-apply-${{ github.ref }}
cancel-in-progress: falseHow to prevent it
- Serialize Terraform jobs with a concurrency group.
- Keep the plan→apply window short, ideally in one job.
- Use backend locking so concurrent writers cannot race the state.