本頁說明如何為 Trusted Cloud 控制台專案設定預設的地區或區域。
當您向 Compute Engine 提出要求時,可能需要根據要求的特定需求來提供地區或區域資訊。凡是涉及地區資源的要求都需要提供地區名稱,而涉及區域資源的要求都需要提供區域名稱。舉例來說,建立靜態外部 IP 位址時必須指定地區,建立虛擬機器 (VM) 執行個體時則必須指定可用區。
建立專案時,Compute Engine 會根據您建立專案的位置,自動選取預設區域和區域。Compute Engine 會嘗試選取靠近專案來源的區域和可用區,以便您建立的資源能縮短客戶或用戶端的延遲時間。如要在其他地區或區域建立資源,可以覆寫預設選取項目。
如要進一步瞭解地區與區域,請參閱地區和區域一文。
如要進一步瞭解全球、區域和地區 Compute Engine 資源,請參閱全球、區域和地區資源。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Trusted Cloud by S3NS 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Trusted Cloud console to access Trusted Cloud by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
安裝 Google Cloud CLI,然後 使用同盟身分登入 gcloud CLI。 登入後,執行下列指令初始化 Google Cloud CLI:
gcloud init
- Set a default region and zone.
預設地區與區域會對您的專案產生什麼影響
預設地區與區域設定只會影響用戶端工具,例如 Google Cloud CLI 和 Trusted Cloud 控制台。使用這些工具建構要求時,工具會自動選取預設區域和地區,協助您管理資源。
使用 Trusted Cloud 主控台建立區域或地區資源 (例如位址和執行個體) 時,Compute Engine 會為您設定區域和可用區欄位。您可以接受預先填入的值,或明確變更其中一或兩個值。
使用 gcloud CLI 時,請省略設定
--region
和--zone
旗標,以便使用新專案的預設區域和可用區屬性。您隨時可以在中繼資料伺服器中變更預設地區和區域設定,也可以在本機覆寫 gcloud CLI 的預設地區和區域,或者使用 gcloud CLI 或 Trusted Cloud 控制台,手動覆寫每個要求的設定。
查詢預設地區或區域
中繼資料伺服器包含與專案有關的中繼資料資訊,包括專案 ID 和專案名稱。您可以查詢中繼資料伺服器以取得及使用有關專案的資訊。
如果您為專案指定預設地區和區域,Compute Engine 會在專案的中繼資料伺服器中設定這些值。
您可以使用下列值來設定預設地區和區域:
google-compute-default-region
google-compute-default-zone
如要查看預設的地區和區域設定,請執行以下
gcloud
指令,並將PROJECT_ID
換成您的專案 ID:gcloud compute project-info describe --project PROJECT_ID
請在回應中找出預設的區域與地區中繼資料值。如果回應中沒有
google-compute-default-region
和google-compute-default-zone
鍵與其值,則表示之前未設定預設的區域或地區。變更預設地區或區域
預設屬性可設定的區域或時區並無限制。例如,您可以將預設區域設在預設地區之外。建立及管理資源時,請檢查預設區域和可用區設定。
主控台
如要變更預設區域或地帶,請按照下列步驟操作:
前往 Trusted Cloud 控制台的「Settings」(設定) 頁面。
從「Region」(地區) 下拉式選單中,選取預設地區。
從「Zone」(區域) 下拉式選單中,選取預設區域。
按一下 [儲存]。
gcloud
您可以向中繼資料伺服器發出要求,變更預設地區和區域。例如:
gcloud compute project-info add-metadata \ --metadata google-compute-default-region=europe-west1,google-compute-default-zone=europe-west1-b
透過任何方法更新預設中繼資料後,請執行
gcloud init
指令,重新初始化default
設定。只有在執行gcloud init
指令後,gcloud CLI 才會重新整理預設地區和區域設定。如要進一步瞭解如何使用 gcloud CLI 選項設定預設區域和地區,請參閱設定預設屬性。
後續步驟
- 進一步瞭解地區和區域。
- 進一步瞭解全域、區域和可用區資源。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-19 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-19 (世界標準時間)。"],[[["\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,[]] -