Problem
When running terraform plan or terraform apply, the operation fails with an error indicating that a gRPC message was received that is larger than the maximum allowed size.
[ERROR] eval: *terraform.EvalDiff, err: rpc error: code = ResourceExhausted desc = grpc: received message larger than max (4797537 vs. 4194304)
The specific message size may vary, but the error code ResourceExhausted and description grpc: received message larger than max are key indicators of this issue.
Cause
This error is not related to system constraints such as memory (RAM) or Docker resource limits. It occurs due to a hardcoded 4MB limit in the gRPC message size for communications between Terraform Core and provider plugins.
When a resource's configuration or resulting state data exceeds this 4MB limit, the gRPC framework rejects the message, causing the Terraform run to fail.
Solution
A feature update to increase the gRPC message size limit to 256MB was implemented in terraform-plugin-go v0.6.0. However, for this change to take effect, individual provider plugins must adopt a version of the terraform-plugin-sdk that includes this update.
Until the provider you are using is updated, the only workaround is to refactor your Terraform configuration to ensure that any single resource's state data remains smaller than 4MB.