Skip to content
Latchkey

Terrateam apply failed in CI

Terrateam runs plan and apply for matched dirspaces from PR comments and posts the result back. An apply failure means the underlying terraform apply exited non-zero (provider error, drift, or a stale plan). The Terrateam comment includes the apply output with the real error.

What this error means

A terrateam apply comment returns a failure status and a comment showing the apply output, with a Terraform error such as a provider failure or a plan that no longer matches state.

terrateam
terrateam apply: failed

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

The underlying terraform apply failed

Terrateam wraps Terraform; the failure is a normal apply error (provider, permissions, resource conflict) surfaced through the comment.

The saved plan went stale before apply

State changed between plan and apply (another run, a merge), so the saved plan no longer applies and Terraform refuses it.

How to fix it

Re-plan, then apply

  1. Read the apply output in the Terrateam comment for the first Error:.
  2. If the plan is stale, comment terrateam plan to produce a fresh plan.
  3. Comment terrateam apply once the new plan is current.
PR comment
terrateam plan
terrateam apply

Fix the underlying Terraform error

For a provider or permissions failure, fix the config or credentials as you would for any Terraform apply, then re-run.

How to prevent it

  • Re-plan after merges so applies use a current plan.
  • Serialize applies per dirspace to avoid stale plans.
  • Fix Terraform errors surfaced in the comment, not the wrapper.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →