Skip to main content

Triage and Remediation

Remediation

Using Console

Here’s how to remediate GCP IAM “Service Limits” (quota) issues using the GCP Console, focusing on IAM-related quotas (service accounts, roles, policy bindings, etc.).

1. Identify Which IAM Limit You’re Hitting

  1. Go to IAM & Admin → Quotas in the GCP Console
    • URL: https://console.cloud.google.com/iam-admin/quotas
  2. In the Services filter, select:
    • IAM Service Account Credentials API, Identity and Access Management (IAM) API, and/or Cloud Resource Manager API, depending on what you’re working with.
  3. Use the Metric filter to locate relevant quotas, for example:
    • Service accounts per project
    • Custom roles per organization/project
    • Policy size / policy bindings per resource
    • API requests per minute/hour
  4. Check which quota shows Usage close to or at Limit or is marked as Blocked.

2. Short-Term Remediation: Reduce Usage (Clean Up IAM Resources)

Depending on which limit is impacted:

A. If you hit service account limits

  1. Go to IAM & Admin → Service Accounts
    • https://console.cloud.google.com/iam-admin/serviceaccounts
  2. Sort or filter by Last used (if available) or by Name/Description to identify unused accounts.
  3. For each unused service account:
    • Click the three dots (⋮)Delete.
  4. If apps can share accounts:
    • Consolidate multiple similar service accounts into fewer, well-scoped service accounts.
    • Update workloads (GCE, GKE, Cloud Run, etc.) to use shared accounts with least-privilege roles.

B. If you hit custom role limits

  1. Go to IAM & Admin → Roles
    • https://console.cloud.google.com/iam-admin/roles
  2. Filter for Custom roles.
  3. Identify:
    • Roles that are deprecated, not used, or duplicate.
  4. For unused custom roles:
    • Click the role → Delete (or Disable first if you want a safe test).
  5. Merge overlapping custom roles where possible so fewer custom roles are needed.

C. If you hit policy size / bindings limits

  1. Go to IAM & Admin → IAM
    • https://console.cloud.google.com/iam-admin/iam
  2. Look for:
    • Members with many roles, or roles with many members.
  3. Reduce bindings:
    • Replace many individual users with Google Groups and assign roles to the group instead.
    • Remove obsolete members or roles that are no longer required.
    • Prefer predefined roles instead of several overlapping custom roles.

D. If you hit IAM API request rate limits

  1. Reduce automation chattiness:
    • Batch IAM changes where possible.
    • Avoid scripts that repeatedly call setIamPolicy / getIamPolicy in tight loops.
  2. Space out calls:
    • Implement backoff and retry in tooling, if you control it.

3. Long-Term Remediation: Request a Quota Increase

  1. Go to IAM & Admin → Quotas
    • https://console.cloud.google.com/iam-admin/quotas
  2. Filter by Service and Metric to locate the specific quota you’re exceeding.
  3. Check the box next to the quota you want to increase.
  4. At the top, click EDIT QUOTAS.
  5. In the side panel:
    • Select a Support case channel (you may need a support plan).
    • Fill in:
      • New limit you’re requesting.
      • Justification (describe workloads, growth, why cleanup alone isn’t enough).
  6. Submit the request and monitor the status in your Support section.

4. Validate After Remediation

  1. Re-run the action that previously failed (e.g., create service account, add IAM binding).
  2. Revisit IAM & Admin → Quotas to confirm:
    • Usage is below limit, or
    • New higher limit is applied.
  3. Optionally, set up internal processes:
    • Periodic review of service accounts, roles, and bindings.
    • Use Groups and standardized roles to control IAM sprawl.
If you share the exact quota metric you’re hitting (e.g., “Service accounts per project” or “Policy size”), I can give exact click-by-click steps tailored to that limit.
For IAM on GCP, “Service Limits” (quotas) can’t actually be raised directly via gcloud; increases are requested via the web console or a support case. With the CLI you can:
  1. Identify what limit you’re hitting
  2. Reduce usage (cleanup / refactor IAM)
  3. Then formally request a quota increase in the console
Below are the concrete CLI steps to diagnose and remediate IAM-related service limits.

1. Identify which IAM limit you’re hitting

Common IAM limits include:
  • Max bindings per policy (e.g., 1,500 bindings on a project)
  • Max roles per principal
  • Max custom roles per project/org
  • Permissions per custom role
Use logs or error messages from failed commands (such as gcloud projects add-iam-policy-binding, gcloud iam roles create, etc.) and note the exact error text, e.g.:
  • RESOURCE_EXHAUSTED
  • Quota exceeded
  • exceeds the maximum number of bindings
  • Maximum number of custom roles reached
There isn’t a direct gcloud command to show IAM policy limits, but you can:
If the bindings count is near/above 1500, you’re hitting the IAM policy bindings limit.

2. Remediate by reducing IAM policy size (clean up via CLI)

2.1 List IAM policy bindings

This lets you see:
  • Roles that are overused or duplicated
  • Direct user/service account bindings that can be replaced by groups

2.2 Remove unused or redundant bindings

  1. Get current policy:
  1. Edit policy.json:
    • Remove bindings you no longer need.
    • Consolidate multiple bindings where possible (e.g., same role with multiple members → one binding with combined members).
Example binding to remove (in policy.json):
Delete that block or remove individual members.
  1. Set the updated policy:
Repeat the same pattern for:
  • gcloud organizations get-iam-policy / set-iam-policy
  • gcloud folders get-iam-policy / set-iam-policy

2.3 Replace individual bindings with group-based bindings

  1. Create or use an existing Google Group in your org (done in Admin Console, not gcloud).
  2. Replace many individual user bindings with a single group binding.
Example: Replace:
With one group binding:
Then remove the per-user bindings as in 2.2.

2.4 Use custom roles to reduce per-binding permission sprawl

If you’re hitting “permissions per custom role” or similar:
  1. Inspect a custom role:
  1. Reduce permissions if there are many rarely-used ones:
  1. If you have many near-identical custom roles, consolidate them into fewer roles with shared permissions.

3. Remediate “too many custom roles” limit

If error mentions maximum custom roles per project/org:
  1. List all custom roles:
  1. Identify unused ones (for example, by last used in your own CMDB / internal docs; GCP doesn’t give per-role usage counts directly via gcloud).
  2. Disable roles you no longer need:
  1. After validation, delete them:
Repeat at org level with --organization=ORG_ID.

4. Request a quota increase (cannot be done via gcloud)

Once you’ve optimized, if you still hit limits you must request a quota increase:
  1. Go to:
    https://console.cloud.google.com/iam-admin/quotas
  2. Filter for:
    • “IAM”
    • Or the specific quota mentioned in your error (e.g., “Policy size”, “Custom roles per project”).
  3. Select the quota → “EDIT QUOTAS” → fill out:
    • Project
    • Contact details
    • New requested limit
    • Justification
  4. Submit and wait for approval.
If you have a support plan, you can also open a support case and reference the error and project ID.

Summary (CLI-only actions)

  • Use gcloud projects/organizations/folders get-iam-policy to inspect policy size and bindings.
  • Clean up and consolidate IAM bindings by editing JSON and applying via set-iam-policy.
  • Use group-based IAM instead of many per-user bindings.
  • Consolidate and clean up custom roles via gcloud iam roles list/update/delete.
  • Any actual increase in the service limit must be requested via the GCP Console or support, not gcloud.
“Service limits” for GCP IAM usually means you’re hitting or about to hit hard limits like:
  • Max role bindings per policy (e.g., 1,500 bindings)
  • Max members per binding
  • API rate limits / quotas for iam.googleapis.com
You can’t change these limits with code, but you can remediate by:
  1. detecting when you’re close to limits
  2. cleaning up unused / duplicate IAM bindings
  3. batching / optimizing calls to stay under API quota
Below is a practical, step‑by‑step approach using Python.

1. Set up Python environment

Make sure your ADC (Application Default Credentials) has permission:
  • roles/resourcemanager.projectIamAdmin for modifying project IAM
  • roles/monitoring.viewer (optional for monitoring quotas)

2. Detect IAM policy “bloat” (bindings/members near limits)

Example: check all IAM bindings on a project and warn if near a threshold.
This doesn’t fix anything yet; it just tells you where you’re likely to hit service limits.

3. Remediate by cleaning up IAM bindings

Typical cleanups:
  • Remove members that no longer exist (users, service accounts)
  • Remove duplicate members
  • Remove roles that are no longer needed
Below is a pattern to:
  • remove specific members from specific roles
  • then write back the cleaned policy
You can extend this logic to:
  • drop bindings where the role is no longer used in your org
  • move many individual users to a Google group and grant the role to the group instead (reduces members per binding)

4. Avoid IAM API quota limits (rate limits)

If your scanner / automation is hitting IAM rate limits, you need to:
  1. Batch operations when possible
  2. Use exponential backoff on 429 / 503 responses
Example of a simple exponential backoff wrapper:

5. Monitor IAM quotas via Cloud Monitoring (optional)

You can track metrics like iam.googleapis.com/quota/allocation/usage and alert when near quota.Basic example to list IAM quota metrics:
You would typically configure alerts in the console, but you can automate that with the Monitoring API if desired.

6. When you truly hit a hard service limit

  • If you hit hard IAM structural limits (e.g., max bindings per policy):
    • Consolidate: use groups instead of many individual members
    • Split: move resources into additional projects / folders so policy is distributed
  • If you hit quota limits (API calls, QPS):
    • Optimize code (batch, cache, backoff)
    • Then request a quota increase in the console (IAM & Admin → Quotas), which cannot be done purely via Python.

If you can share:
  • which exact IAM service limit you’re hitting (bindings, members, API QPS, etc.) I can give you a more targeted Python snippet tailored to that specific limit.
GCP IAM service limits (e.g., number of roles per principal, policy size, etc.) are enforced by Google and are not configurable via Terraform or the Google provider; to remediate limit issues you must request a quota/limit increase in the Cloud Console (IAM & Admin → Quotas) or via gcloud services quotas where available. terraform plan cannot show a quota change because it is outside Terraform’s control.