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 requests involving zonal resources requires that you supply a zone name and any requests involving regional resources requires that you supply a region name. For example, requests involving a VM instance always requires a zone specification and requests involving a static external IP address always requires a region specification.
When you create a new project, Compute Engine automatically selects a default region and zone for the project, based on the location from where the project was created. Compute Engine attempts to pick a region and a zone that are close to where the project originated so that resources you create have reduced latency to your customers or clients. You can override the default zone and region for a project if you want to create resources in a different region or zone instead.
To learn more about regions and zones, read the Regions and Zone documentation.
To learn more about global, regional, and zonal Compute Engine resources, read the Global, Regional, and Zonal Resources documentation.
Before you begin
- If you want to use the command-line examples in this guide:
How a default region and zone affects your project
The default region and zone settings affect only client tools such as
gcloud and the Google Cloud Platform Console. Both of these tools use the default zone
and region information to help you manage resources more easily by automatically
pre-selecting the zone and region when you construct your requests.
In the GCP Console, zone and region fields are pre-populated when you create zonal or regional resources like instances and addresses. You can simply accept the pre-populated values, or explicitly change the value.
gcloud tool, you can omit the
--region flags and
the tool uses the default zone and region properties for the project.
You can always change your default region and zone in the metadata server,
override the default zone and region locally for the
gcloud tool, or override
it manually for each request in both the
gcloud tool and the Google Cloud Platform Console.
Looking up the default zone or region
The metadata server contains metadata information about a project, including the project ID, project name, and so on. 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 compute project-info describe --project [PROJECT_ID]
[PROJECT_ID] is your project ID.
Look for the default zone and region metadata values in the response. If the
keys and values are missing from the response, that means no default zone or
region is set.
Changing the default zone or region
To change your default zone or region in the GCP Console:
- In the GCP Console, go to the Settings page.
- From the Region menu, select your default region.
- From the Zone menu, select your default zone.
You can change the default zone and region in your metadata server 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 through any method, run
to reinitialize your
default configuration. The
gcloud command-line tool
picks up the new default zone and region changes only after you rerun the
gcloud init command.
For more information about
gcloud options that can be used to set default
zones and regions, review the
setting default properties