When you make a request to Compute Engine, you might be required to provide a region or a zone depending on the specific requirements of your request. Any request involving regional resources requires that you supply a region name, and any request involving zonal resources requires that you supply a zone name. For example, you must specify a region when you create a static external IP address, and you must specify a zone when you create a virtual machine (VM) instance.
When you create a project, Compute Engine automatically selects a default region and zone based on the location from which you create the project. Compute Engine attempts to pick a region and a zone that are close to where the project originates so that resources you create have reduced latency to your customers or clients. If you want to create resources in a different region or zone, you can override the default selection.
For more information about regions and zones, see Regions and zones.
For more information about global, regional, and zonal Compute Engine resources, see Global, regional, and zonal resources.
Before you begin
- If you want to use the command-line examples in this guide, do the following:
How a default region and zone affect your project
The default region and zone settings affect only client tools, such as the
gcloud command-line tool and the Google Cloud Console. When you use these tools to
construct your requests, the tools help you manage resources by automatically
selecting the default region and zone.
When you use the Cloud Console to create regional or zonal resources like addresses and instances, Compute Engine sets the region and zone fields for you. You can accept the pre-populated values or explicitly change one or both of the values.
When you use the
gcloud tool, omit setting the
--zone flags to use the default region and zone properties for the new
You can always change the default region and zone settings in the metadata
server, override the default region and zone locally for the
gcloud tool, or override the settings manually for each request
by using either the
gcloud tool or the Cloud Console.
Looking up the default region or zone
The metadata server contains metadata information about a project, including the project ID and project name. You can query the metadata server to get and use information about the project.
If you specify a default region and zone for your project, then Compute Engine sets these values in the metadata server for your project.
Default regions and zones are set by using the following values:
To see what your default region and zone settings are, run the following
gcloud command, replacing
PROJECT_ID with your project ID:
gcloud compute project-info describe --project PROJECT_ID
Look for the default region and zone metadata values in the response. If the
keys and values are missing from the response, that means no default region
or zone is set.
Changing the default region or zone
There are no restrictions on which regions or zones you can set for your default properties. For example, it is possible to set a default zone that is outside of your default region. Check the default region and zone settings when creating and managing your resources.
To change your default region or zone, follow these steps:
In the Cloud Console, go to the Settings page.
From the Region drop-down menu, select a default region.
From the Zone drop-down menu, select a default zone.
You can change the default region and zone by making a request to the metadata server. For example:
gcloud compute project-info add-metadata \ --metadata google-compute-default-region=europe-west1,google-compute-default-zone=europe-west1-b
After you update the default metadata by using any method, run the
gcloud init command to reinitialize your
gcloud tool refreshes the default region and zone settings
only after you run the
gcloud init command.
For more information about using the
gcloud tool options to set default
regions and zones, see
Set default properties.