您可以使用 Google Cloud 控制台、gcloud CLI 或 REST 查看這些承諾使用合約。
事前準備
-
如果尚未設定驗證,請先完成設定。驗證程序會確認您的身分,以便授予 Google Cloud 服務和 API 的存取權。如要從本機開發環境執行程式碼或範例,您可以選取下列其中一個選項,向 Compute Engine 進行驗證:
請根據您打算如何使用本頁範例,選取對應的分頁標籤:
控制台
使用 Google Cloud 控制台存取 Google Cloud 服務和 API 時,不需要設定驗證機制。
gcloud
-
安裝 Google Cloud CLI。 安裝完成後,請執行下列指令,初始化 Google Cloud CLI:
gcloud init若您採用的是外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。
-
- 設定預設區域和可用區。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI。
若您採用的是外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。
詳情請參閱 Google Cloud 驗證說明文件中的「使用 REST 進行驗證」一節。
必要的角色
如要取得查看資源承諾使用合約所需的權限,請要求管理員授予您專案的 Compute 檢視者 (roles/compute.viewer) 或 Compute 管理員 (roles/compute.admin) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
這個預先定義的角色具備 compute.commitments.get 和 compute.commitments.list 權限,可查看資源型承諾使用合約。
查看承諾使用合約清單
您可以使用Google Cloud 控制台、gcloud CLI 或 REST,查看專案中所有承諾使用合約的清單。
控制台
前往 Google Cloud 控制台的「Committed use discounts」(承諾使用折扣) 頁面。 前往「Committed use discounts」(承諾使用折扣) 頁面
如要查看特定類別的使用承諾清單,請選取下列其中一個分頁標籤:
- 「Hardware commitments」(硬體承諾使用合約):選取這個分頁,即可查看硬體資源的承諾使用合約,例如 vCPU、記憶體、GPU、本機 SSD 磁碟和單一租戶節點。
- 軟體授權承諾使用合約:選取這個分頁,即可查看 OS 授權的承諾使用合約。
- 區塊儲存空間承諾使用合約:選取這個分頁,即可查看 Exapool 容量的承諾使用合約。
gcloud
如要列出特定區域中的所有承諾使用合約,請使用 gcloud compute commitments list 指令:
gcloud compute commitments list \
--regions=REGION \
--project=PROJECT_ID
更改下列內容:
REGION:要查看承諾使用合約的區域。PROJECT_ID:專案 ID。
範例
舉例來說,如要使用 project-list-example 專案列出 us-central1 區域中的承諾使用合約,請執行下列指令:
gcloud compute commitments list \
--regions=us-central1 \
--project=project-list-example
REST
如要列出特定區域中的承諾使用合約,請向 regionCommitments.list 方法發出 GET 要求:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/commitments
如要列出專案中所有區域的承諾使用合約,請向 regionCommitments.aggregatedList 方法發出 GET 要求:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/aggregated/commitments
更改下列內容:
PROJECT_ID:要查看承諾使用合約的專案 ID。REGION:要查看承諾使用合約的區域。
查看特定承諾使用合約的詳細資料
您可以查看承諾使用合約的詳細屬性,例如:
- 狀態
- 承諾使用方案
- 承諾使用合約開始和結束時間
- 自動續約設定
- 承諾資源類型和數量
您可以使用 Google Cloud 控制台、gcloud CLI 或 REST 查看承諾使用合約。
控制台
前往 Google Cloud 控制台的「Committed use discounts」(承諾使用折扣) 頁面。 前往「Committed use discounts」(承諾使用折扣) 頁面
選取要查看的承諾使用合約類別分頁標籤:
- 如要查看硬體資源的承諾使用合約,請按一下「Hardware commitments」(硬體承諾使用合約) 分頁標籤。硬體承諾使用合約涵蓋 vCPU、記憶體、GPU、本機 SSD 磁碟和單一租戶節點。
- 如要查看付費軟體授權的承諾使用合約,請選取「Software license commitments」(軟體授權承諾使用合約) 分頁標籤。授權承諾使用合約涵蓋作業系統 (OS) 授權,例如 SUSE Linux Enterprise Server (SLES)、SLES for SAP 或 Red Hat Enterprise Linux (RHEL)。
- 如要查看網路附加儲存空間集區的使用承諾,請選取「Block storage commitments」(區塊儲存空間使用承諾) 分頁標籤。區塊儲存空間承諾使用合約涵蓋 Exapool 容量。
如要查看承諾使用合約的詳細資料頁面,請按一下承諾使用合約的名稱。
gcloud
如要描述特定承諾使用合約,請使用 gcloud compute commitments describe 指令:
gcloud compute commitments describe COMMITMENT_NAME \
--region=REGION \
--project=PROJECT_ID
更改下列內容:
COMMITMENT_NAME:承諾使用合約的名稱。REGION:承諾使用合約所在的區域。PROJECT_ID:專案 ID。
範例
以下範例說明 myproject 專案和 us-central1 區域中的承諾使用合約。
範例 1:說明硬體承諾使用合約
如要說明現有的硬體承諾使用合約 (example-hardware-commitment),請執行下列指令:
gcloud compute commitments describe example-hardware-commitment \
--region=us-central1 \
--project=myproject
指令會傳回承諾使用合約的屬性,類似如下:
autoRenew: true category: MACHINE creationTimestamp: '2025-05-15T09:30:00.000-07:00' endTimestamp: '2026-05-15T09:30:00.000-07:00' kind: compute#commitment name: example-hardware-commitment plan: TWELVE_MONTH region: https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1 resources: - amount: '4' type: VCPU - amount: '16384' type: MEMORY status: ACTIVE type: GENERAL_PURPOSE
範例 2:說明區塊儲存空間承諾使用合約
如要說明現有的區塊儲存空間承諾使用合約 (example-block-storage-commitment),請執行 gcloud beta compute commitments describe 指令:
gcloud beta compute commitments describe example-block-storage-commitment \
--region=us-central1 \
--project=myproject
指令會傳回承諾使用合約的屬性,建立承諾使用合約與 Exapool 的關係,如下所示:
autoRenew: true category: PERSISTENT_DISK creationTimestamp: '2025-08-20T14:45:00.000-07:00' endTimestamp: '2026-08-20T14:45:00.000-07:00' kind: compute#commitment name: example-block-storage-commitment persistentDiskResources: - amount: '102400' dimensionType: CAPACITY_OPTIMIZED productType: HYPERDISK_EXAPOOL_BALANCED plan: TWELVE_MONTH region: https://www.googleapis.com/compute/beta/projects/myproject/regions/us-central1 status: ACTIVE
REST
向 regionCommitments.get 方法發出 GET 要求:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/commitments/COMMITMENT_NAME
更改下列內容:
PROJECT_ID:專案 ID。REGION:購買承諾使用合約的區域。COMMITMENT_NAME:承諾使用合約的名稱。
範例
下列範例會擷取 myproject 專案和 us-central1 區域中的承諾使用合約詳細資料。
範例 1:說明硬體承諾使用合約
如要擷取硬體承諾使用合約 (example-hardware-commitment) 的屬性,請提出下列 GET 要求:
GET https://compute.googleapis.com/compute/v1/projects/myproject/regions/us-central1/commitments/example-hardware-commitment
回應包含硬體承諾使用合約的屬性,輸出內容大致如下:
{
"autoRenew": true,
"category": "MACHINE",
"creationTimestamp": "2025-05-15T09:30:00.000-07:00",
"endTimestamp": "2026-05-15T09:30:00.000-07:00",
"kind": "compute#commitment",
"name": "example-hardware-commitment",
"plan": "TWELVE_MONTH",
"region": "https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1",
"resources": [
{
"amount": "4",
"type": "VCPU"
},
{
"amount": "16384",
"type": "MEMORY"
}
],
"status": "ACTIVE",
"type": "GENERAL_PURPOSE"
}
範例 2:說明區塊儲存空間承諾使用合約
如要擷取區塊儲存空間承諾使用合約 (example-block-storage-commitment) 的屬性,請向 beta regionCommitments.get 方法發出下列 GET 要求:
GET https://compute.googleapis.com/compute/beta/projects/myproject/regions/us-central1/commitments/example-block-storage-commitment
回應包含代表區塊儲存空間承諾使用容量的屬性,類似於下列 JSON 輸出內容:
{
"autoRenew": true,
"category": "PERSISTENT_DISK",
"creationTimestamp": "2025-08-20T14:45:00.000-07:00",
"endTimestamp": "2026-08-20T14:45:00.000-07:00",
"kind": "compute#commitment",
"name": "example-block-storage-commitment",
"persistentDiskResources": [
{
"amount": "102400",
"dimensionType": "CAPACITY_OPTIMIZED",
"productType": "HYPERDISK_EXAPOOL_BALANCED"
}
],
"plan": "TWELVE_MONTH",
"region": "https://www.googleapis.com/compute/beta/projects/myproject/regions/us-central1",
"status": "ACTIVE"
}