terraform runtime_error ai_generated partial

Error: The plan output exceeds the maximum allowed size of 4 MB

ID: terraform/plan-output-too-large

Also available as: JSON · Markdown · 中文
80%Fix Rate
80%Confidence
1Evidence
2024-01-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.6.0 active
1.7.0 active
1.8.0 active

Root Cause

The Terraform plan file is too large due to many resources or large state data, exceeding the 4 MB limit for plan serialization.

generic

中文

由于资源过多或状态数据过大,Terraform 计划文件超过 4 MB 的计划序列化限制。

Official Documentation

https://developer.hashicorp.com/terraform/cli/commands/plan

Workarounds

  1. 85% success Reduce the number of resources in a single plan by using Terraform modules or splitting into separate configurations. For example, break a large VPC setup into smaller modules.
    Reduce the number of resources in a single plan by using Terraform modules or splitting into separate configurations. For example, break a large VPC setup into smaller modules.
  2. 90% success Use 'terraform plan -out=plan.tfplan' and then 'terraform show plan.tfplan' to view the plan, instead of relying on the full output.
    Use 'terraform plan -out=plan.tfplan' and then 'terraform show plan.tfplan' to view the plan, instead of relying on the full output.

中文步骤

  1. 通过使用 Terraform 模块或拆分为单独的配置来减少单个计划中的资源数量。例如,将大型 VPC 设置拆分为较小的模块。
  2. 使用 'terraform plan -out=plan.tfplan' 然后 'terraform show plan.tfplan' 查看计划,而不是依赖完整输出。

Dead Ends

Common approaches that don't work:

  1. 95% fail

    Increasing the timeout or retrying the plan does not reduce the plan size.

  2. 75% fail

    Splitting the configuration into multiple workspaces without reducing resource count still results in large plans.