# 错误：计划输出超过最大允许大小 4 MB；请尝试减少资源数量或使用二进制计划文件

- **ID:** `terraform/plan-output-encoding-error`
- **领域:** terraform
- **类别:** encoding_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

由于资源数量过多或属性值过大，JSON 格式的计划输出过大（超过 4 MB）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Terraform v1.6.0 | active | — | — |
| Terraform v1.7.0 | active | — | — |
| Terraform v1.8.0 | active | — | — |

## 解决方案

1. ```
   使用 'terraform plan -out=plan.tfplan' 生成二进制计划文件而不是 JSON 输出，没有大小限制。
   ```
2. ```
   如果需要 JSON 输出，使用 'terraform plan -target=资源类型.名称' 减少计划范围，专注于特定资源。
   ```
3. ```
   使用 'terraform plan -compact-warnings' 和 'terraform plan -no-color' 减少输出冗余。
   ```

## 无效尝试

- **** — The JSON output is what exceeds the limit, not the binary plan. (80% 失败率)
- **** — Complex dependencies between resources may cause state fragmentation. (70% 失败率)
- **** — Apply may still fail or produce unexpected results without a plan. (60% 失败率)
