A CI pipeline applies `dev` successfully, then the `prod` stage applies `dev`'s plan file to prod state.
AdvancedTroubleshootingPartial Applies, Version Mismatches and CI Failures
Answer
Likely causes → Artifact name collision (tfplan used for both stages) or a missing -backend-config switch between stages. Terraform may error (Saved plan does not match the given state/stale) or, worse, apply with dev vars if the job re-plans with the wrong var file.
Diagnose → Check artifact names, the var file and backend config used in each stage's logs.
Fix → Stop the pipeline, inspect prod changes from the apply log, and correct with a proper prod plan.
Prevent → Name artifacts tfplan-<env>-<sha>, run each environment in its own directory/job with explicit -backend-config=backends/<env>.hcl and -var-file=env/<env>.tfvars, and print account ID + workspace before apply.
More on Partial Applies, Version Mismatches and CI Failures
An apply failed halfway: 14 resources created, then `Error: creating RDS DB Instance ... InvalidParameterCombination`. What state are you in?Beginner`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.`IntermediateApply job fails: `Failed to read plan from plan file` — `The given plan file was created by Terraform v1.9.5, but this is v1.9.8.`Intermediate`Error: Unsupported Terraform Core version` — `This configuration does not support Terraform version 1.5.7.`BeginnerA teammate with Terraform 1.10 applied; now your 1.6 gets `state snapshot was created by Terraform v1.10.0, which is newer than current v1.6.6; upgrade to Terraform v1.10.0 or greater to work with this state`.Intermediate`Error: Resource instance managed by newer provider version` — `The current state of aws_instance.web was created by a newer provider version than is currently selected.`Intermediate