Terraform Cloud "Cannot apply ... plan ... discarded" in CI
The apply step tried to confirm a run whose plan is no longer applicable. HCP Terraform discards a plan when a newer run supersedes it, when it is discarded manually, or when it ages out, so the stale run cannot be applied.
What this error means
A pipeline that plans, then confirms in a later step, fails with "Error: Cannot apply a run that has been discarded" or that the run was superseded.
Error: Cannot apply run run-ABC123
The run was discarded because a newer run for the workspace superseded it.Common causes
A newer run superseded the plan
A second push or a concurrent pipeline queued a new run, and HCP Terraform discarded the older pending plan.
The plan aged out or was discarded
A plan left pending too long, or discarded in the UI, cannot then be applied.
How to fix it
Re-plan and apply in one flow
- Avoid a long gap between plan and apply so the plan cannot be superseded.
- Serialize pipeline runs per workspace to prevent overlap.
- Re-run the plan, then apply the fresh run.
terraform plan -out=tfplan
terraform apply tfplanPrevent concurrent runs
Use concurrency controls so only one run per workspace is in flight, so a later run cannot discard the one you are applying.
concurrency:
group: tf-${{ github.workflow }}-prod
cancel-in-progress: falseHow to prevent it
- Keep plan and apply close together in the pipeline.
- Serialize runs per workspace with a concurrency group.
- Do not manually discard runs a pipeline is about to apply.