When I try to create a new IAM user in GCP, I get the following error
Request "Create IAM Members roles/dns.admin serviceAccount:[email protected]
for \"project \\\"projectId\\\"\"" returned error:
Error applying IAM policy for project "projectId": Error setting IAM policy for project "projectId": googleapi: Error 400:
The size of the policy is too large.
Consider removing or merging some of the bindings or if using conditions remove
any lengthy conditions., badRequest
Above shown is the output from terraform apply command. When I try to use gcloud cli, I get a similar output as well When I try to create it through GCP console, it just shows "backend error"
Most likely you hit one of the quotas of IAM. All the bindings you specified in Terraform are uploaded every time you perform an update or create. As the error says you are probably creating a lot of bindings that could be merged together. I suggest trying to find which quota limit you are reaching and why, here are some debugging commands:
Number of iam bindings:
Total size of the bindings:
Occurence of each member in all the bindings:
Then, you could reduce the number of bindings by merging. For example, this binding:
Could be merged to this: