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 Cloud Platform 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
Compute Engine sets the default region and zone by setting two values in the project's metadata server. The metadata server contains metadata information about the project, including the project ID, project name, and so on. You can query the metadata server to get and use information about the project.
In the metadata server, the following two metadata values are set by default:
To see what your default region and zone settings are, run the following
gcloud command, replacing
PROJECT_ID with the
project that you want to get the information about. If you omit the project ID,
the gcloud` tool will use your default project.
gcloud compute project-info describe --project PROJECT_ID
Look for the default zone and region metadata values in the response.
Changing the default zone or region
To change a default region or zone in the metadata server in using the
gcloud tool, read
Change your default zone and region in the metadata server
To change your default zone or region in the Cloud Platform Console:
- Go to the Metadata pane in the Cloud Platform Console.
- Click the Edit button and update the default zone and region values.