TERRAFORM_STALE_PLAN cicd config_error ai_generated true

错误:保存的计划已过时。自计划保存以来,配置已发生更改。

Error: Saved plan is stale. The configuration has changed since the plan was saved.

ID: cicd/terraform-plan-stale

其他格式: JSON · Markdown 中文 · English
92%修复率
85%置信度
1证据数
2023-08-10首次发现

版本兼容性

版本状态引入弃用备注
Terraform 1.5.0 active — — —
OpenTofu 1.6.0 active — — —

根因分析

Terraform计划是从旧版本的配置文件生成的,但在应用计划之前配置已被修改,导致校验和不匹配。

English

Terraform plan was generated from an older version of the configuration files, but the configuration was modified before the plan could be applied, causing a checksum mismatch.

generic

官方文档

https://developer.hashicorp.com/terraform/cli/commands/plan#planning-and-applying-in-automation

解决方案

  1. Re-run `terraform plan -out=tfplan` to generate a fresh plan, then apply with `terraform apply tfplan`
  2. In CI/CD pipelines, run plan and apply in the same job without intermediate steps that modify config files (e.g., use a single workflow step: `terraform plan -out=tfplan && terraform apply tfplan`)

无效尝试

常见但无效的做法:

  1. 100% 失败

    Terraform will reject the apply because the plan file's checksum doesn't match the current config; it will fail with the same error

  2. 95% 失败

    Plan files are binary and checksummed; manual editing corrupts the file and terraform will refuse to apply it