Getting error when tfstate is larger than 4MB

We’re storing our tfstate files in our documentDB (AWS mongodb compatible database) with a HTTP REST API in front of it using the HTTP backend, which has been fine thus far but it seems the size of the state file has crossed the 4MB threshold and the terraform apply worked fine but now I can’t do a terraform destroy because I’m getting the error rpc error: code = ResourceExhausted desc = grpc: received message larger than max (5429624 vs. 4194304)

Is there a way we can increase this limit for the backend?

Here’s an interesting discussion about this error:

Are you using data.local_file by any chance?

Thanks for getting back to me. I had read through a few of the issues googling the error popped up figuring that it was because the state file was too large. I apologise though I meant to respond to this thread myself as I figured out that I had not filtered the terraform state from the documentdb query and thus terraform was storing a copy of the state file within the state file as part of the HTTP providers response, thus ballooning the size of the state file with every run of terraform. All resolved now that I’ve filtered the query to only return the relevant document

1 Like