Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Is it possible to let to GCP choose availability zone?

  During a new VM launch,  GCP console allows to choose 'region' and 'zone', that translates to 'zone' in GCP CLI. For instance, '--zone=us-central1-a'.
  Occasionally, my 'gcloud compute instances create' fails with the following error 'code: ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS'.  I.e. choose zone doesn't have enough capacity for my instance type. It will be nice to have the ability to ask GCP to launch a new VM in a certain region, in any availability zone (as we have in another cloud provider). But I couldn't find such feature....

Solved Solved
1 4 778
1 ACCEPTED SOLUTION

Hi @vitaly_il ,

A workaround would be to create a managed instance group (MIG) with a max size of 1 and with the distribution shape [1] set to "ANY". The VM will be created in any zone that has the resources required for the VM.

[1] https://cloud.google.com/compute/docs/instance-groups/regional-mig-distribution-shape#how_any_works

View solution in original post