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

- **ID:** `cicd/terraform-plan-stale`
- **领域:** cicd
- **类别:** config_error
- **错误码:** `TERRAFORM_STALE_PLAN`
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Terraform 1.5.0 | active | — | — |
| OpenTofu 1.6.0 | active | — | — |

## 解决方案

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`)
   ```

## 无效尝试

- **** — Terraform will reject the apply because the plan file's checksum doesn't match the current config; it will fail with the same error (100% 失败率)
- **** — Plan files are binary and checksummed; manual editing corrupts the file and terraform will refuse to apply it (95% 失败率)
