The Scenario
You’re running a gcloud compute instances create command or triggering a Managed Instance Group resize to 50 VMs during a pre-planned scaling event. The deployment fails abruptly, and your CI pipeline exits with a non-zero status, blocking the release.
Symptoms
- The
gcloudcommand returns:ERROR: (gcloud.compute.instances.create) Could not fetch resource: Quota 'CPUS_ALL_REGIONS' exceeded. Limit: 100.0. - In the GCP Console, the error appears as:
Quota exceeded for quota metric 'Compute Engine API' and limit 'CPUS_ALL_REGIONS'. - Managed Instance Group (MIG) operations show VMs in
STOPPINGorPROVISIONINGstate that never become healthy.
Root Cause
GCP enforces regional and global resource quotas to prevent accidental resource overconsumption. The error occurs because your project has hit a hard limit on a specific quota metric (e.g., CPUs, GPUs, IP addresses) in a given region. This is not a billing issue — it’s a capacity reservation mechanism. The quota is checked at request time, and if the requested resources plus existing usage exceed the limit, the API rejects the operation.
Resolution (Step-by-Step)
-
Identify the exact quota that’s exceeded:
gcloud compute regions describe <your-region> # Look for the "quotas" sectionOr use the Console: IAM & Admin > Quotas.
-
Check current usage vs. limit:
gcloud compute regions describe <your-region> --format="json(quotas)" -
Request a quota increase:
- Go to IAM & Admin > Quotas in the GCP Console.
- Filter by service: “Compute Engine API”.
- Find the specific metric (e.g., “CPUs” in region
us-central1). - Select the checkbox, click “EDIT QUOTAS”, and submit a request. Provide a brief justification (e.g., “Scaling web service for peak load”).
-
Temporarily reduce your request size to fit within the current quota:
gcloud compute instances create <instance-name> --zone=<zone> --machine-type=n1-standard-2 # Instead of requesting 10 VMs at once, create them sequentially or in smaller batches.
Why This Sometimes Doesn’t Work
Quota increase requests are not instant — they require manual review and can take hours or days. If you’re in the middle of a production incident, this is a non-starter. Also, some quotas (like GPUs) have hard regional limits that cannot be increased without an exception from Google. The workaround is to use a different region or instance type that has available quota. You can also delete unused resources (e.g., stopped instances, snapshots, static IPs) to free up quota immediately.
Verification
gcloud compute instances create test-quota-vm --zone=<zone> --machine-type=e2-micro
# Expected output: "Created [https://www.googleapis.com/compute/v1/projects/...]"
If the command succeeds, the quota issue is resolved. For MIGs, check the group status:
gcloud compute instance-groups managed list-instances <mig-name> --region=<region>
# All instances should show "RUNNING" status.
Common Follow-up Questions
Q: Why does my quota show enough CPUs but I still get the error? A: You might be hitting a different quota, like “Preemptible CPUs” or “In-use IP addresses”. Check the exact metric name in the error message.
Q: Can I automate quota increase requests?
A: Not directly — the API doesn’t support automatic increases. You can use the gcloud alpha quotas commands to programmatically check and request increases, but approval is still manual.
Q: Does deleting a VM immediately free up quota? A: Yes, but there’s a short propagation delay (up to a few minutes). Stopped instances still consume quota.
Prevent This in the Future
Set up proactive monitoring on your GCP quota usage to alert you when you’re approaching limits, not when you hit them. This lets you request increases during business hours rather than during an incident. Tools like Better Stack can track quota metrics from the GCP Monitoring API and send alerts via email, Slack, or PagerDuty when usage exceeds a threshold (e.g., 80% of limit). Set up uptime monitoring and alerts with Better Stack