[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-11。"],[[["\u003cp\u003eThis page explains how to set and manage default regions and zones for your Google Cloud project, which are necessary for creating regional and zonal resources like static IP addresses and virtual machine instances.\u003c/p\u003e\n"],["\u003cp\u003eCompute Engine automatically selects a default region and zone based on the project's origin, but users can override these defaults to create resources in different locations, to reduce latency.\u003c/p\u003e\n"],["\u003cp\u003eDefault region and zone settings affect client tools like the Google Cloud CLI and Google Cloud console by automatically pre-populating these values when creating resources, but can be manually changed or overridden.\u003c/p\u003e\n"],["\u003cp\u003eYou can check your current default region and zone settings by querying the metadata server using the \u003ccode\u003egcloud compute project-info describe\u003c/code\u003e command, which will list \u003ccode\u003egoogle-compute-default-region\u003c/code\u003e and \u003ccode\u003egoogle-compute-default-zone\u003c/code\u003e if they are set.\u003c/p\u003e\n"],["\u003cp\u003eThe default region and zone can be modified either through the Google Cloud console settings page, or by using the \u003ccode\u003egcloud compute project-info add-metadata\u003c/code\u003e command to update the metadata server, followed by the \u003ccode\u003egcloud init\u003c/code\u003e command to refresh the local configuration.\u003c/p\u003e\n"]]],[],null,["# Changing the default region or zone\n\n*** ** * ** ***\n\nThis page explains how to set a default\n[region or zone](/compute/docs/regions-zones) for your Google Cloud console\n[project](/resource-manager/docs/creating-managing-projects).\n\nWhen you make a request to Compute Engine, you might be required to\nprovide a region or a zone depending on the specific requirements of your\nrequest. Any request involving\n[regional](/compute/docs/regions-zones/global-regional-zonal-resources#regionalresources)\nresources requires that you supply a region name, and any request involving\n[zonal](/compute/docs/regions-zones/global-regional-zonal-resources#zoneresource)\nresources requires that you supply a zone name. For example, you must specify\na region when you create a static external IP address, and you must specify\na zone when you create a virtual machine (VM) instance.\n\nWhen you create a project, Compute Engine automatically selects\na default region and zone based on the location from which you create the\nproject. Compute Engine attempts to pick a region and a\nzone that are close to where the project originates so that resources you\ncreate have reduced latency to your customers or clients. If you want to\ncreate resources in a different region or zone, you can override the default\nselection.\n\nFor more information about regions and zones, see\n[Regions and zones](/compute/docs/regions-zones).\n\nFor more information about global, regional, and zonal Compute Engine\nresources, see\n[Global, regional, and zonal resources](/compute/docs/regions-zones/global-regional-zonal-resources).\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\nHow a default region and zone affect your project\n-------------------------------------------------\n\nThe default region and zone settings affect only client tools, such as the\nGoogle Cloud CLI and the Google Cloud console. When you use these tools to\nconstruct your requests, the tools help you manage resources by automatically\nselecting the default region and zone.\n\nWhen you use the Google Cloud console to create regional or zonal resources\nlike addresses and instances, Compute Engine sets the region and zone\nfields for you. You can accept the pre-populated values or explicitly change\none or both of the values.\n\nWhen you use the gcloud CLI, omit setting the `--region` and\n`--zone` flags to use the default region and zone properties for the new\nproject.\n\nYou can always change the default region and zone settings in the metadata\nserver, override the default region and zone locally for the\ngcloud CLI, or override the settings manually for each request\nby using either the gcloud CLI or the Google Cloud console.\n\nLooking up the default region or zone\n-------------------------------------\n\nThe metadata server contains metadata information about a project, including\nthe project ID and project name. You can query the metadata server to get\nand use information about the project.\n\nIf you specify a default region and zone for your project, then\nCompute Engine sets these values in the\n[metadata server](/compute/docs/storing-retrieving-metadata) for your project.\n\nDefault regions and zones are set by using the following values:\n\n- `google-compute-default-region`\n- `google-compute-default-zone`\n\nTo see what your default region and zone settings are, run the following\n[`gcloud`](/compute/docs/gcloud-compute) command, replacing\n\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID: \n\n gcloud compute project-info describe --project \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\nLook for the default region and zone metadata values in the response. If the\n`google-compute-default-region` and `google-compute-default-zone`\nkeys and values are missing from the response, that means no default region\nor zone is set.\n\nChanging the default region or zone\n-----------------------------------\n\nThere 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. \n\n### Console\n\nTo change your default region or zone, follow these steps:\n\n1. In the Google Cloud console, go to the **Settings** page.\n\n [Go to Settings](https://console.cloud.google.com/compute/settings)\n2. From the **Region** drop-down menu, select a default region.\n\n3. From the **Zone** drop-down menu, select a default zone.\n\n4. Click **Save**.\n\n### gcloud\n\nYou can change the default region and zone\nby making a request to the\n[metadata](/compute/docs/storing-retrieving-metadata) server. For example: \n\n```\ngcloud compute project-info add-metadata \\\n --metadata google-compute-default-region=europe-west1,google-compute-default-zone=europe-west1-b\n```\n\nAfter you update the default metadata by using any method, run the\n`gcloud init` command to reinitialize your `default` configuration.\nThe gcloud CLI refreshes the default region and zone settings\nonly after you run the `gcloud init` command.\n\nFor more information about using the gcloud CLI options to set default\nregions and zones, see\n[Set default properties](/compute/docs/gcloud-compute#default-properties).\n\nWhat's next\n-----------\n\n- Learn more about [regions and zones](/compute/docs/regions-zones).\n- Learn more about [global, regional, and zonal resources](/compute/docs/regions-zones/global-regional-zonal-resources)."]]