本文說明如何刪除預訂。如要瞭解如何刪除未來預留項目要求,請改為參閱「取消或刪除未來預留項目要求」。
刪除預留項目,以免繼續產生不再需要的預留資源費用。
限制
刪除預訂項目之前,請先考量以下事項:
您只能在建立共用預訂的專案中刪除該預訂。
只有在沒有 Compute Engine 執行個體耗用明確指定的預留項目時,您才能刪除該項目。如果任何執行個體使用預留資源,請先採取下列任一做法,再刪除預留資源:
只有在預留項目期限結束後,您才能刪除系統自動建立的未來預留項目。
如要刪除附加至承諾的預訂項目,請先更換預訂項目,將其從承諾中分離。
事前準備
-
如果尚未設定驗證,請先完成設定。
「驗證」是指驗證身分的程序,確認您有權存取 Google Cloud 服務和 API。如要從本機開發環境執行程式碼或範例,請選取下列其中一個選項,向 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
在 Google Cloud 控制台,前往「Reservations」(預留項目) 頁面。
在「On-demand reservations」(隨需預留項目) 分頁 (預設),選取要刪除的預留項目。
按一下「刪除」圖示
。按一下「Delete」(刪除) 確認操作。
RESERVATION_NAME
:預訂名稱。ZONE
:預留項目所在的可用區。PROJECT_ID
:您建立預留資源的專案 ID。ZONE
:預留項目所在的可用區。RESERVATION_NAME
:預訂名稱。- 瞭解如何查看預訂資訊。
Go
如要在本機開發環境中使用本頁的 Go 範例,請安裝並初始化 gcloud CLI,然後使用使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
Java
如要在本機開發環境中使用本頁的 Java 範例,請安裝並初始化 gcloud CLI,然後使用使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
Node.js
如要在本機開發環境中使用本頁的 Node.js 範例,請安裝並初始化 gcloud CLI,然後使用使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
Python
如要在本機開發環境中使用本頁的 Python 範例,請安裝並初始化 gcloud CLI,然後使用使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
詳情請參閱 Google Cloud 驗證說明文件中的「Authenticate for using REST」。
必要的角色
如要取得刪除預訂所需的權限,請要求管理員授予您專案的 Compute 管理員 (
roles/compute.admin
) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。這個預先定義的角色具備
compute.reservations.delete
權限,這是刪除預訂項目時的必要權限。刪除預留項目
如果您刪除可供任何相符的運算執行個體自動使用的保留項目,則使用已刪除保留項目的執行個體會繼續執行。您仍須支付這些執行個體的費用。
你可以一次刪除單一或多個預訂。如要預訂多個座位,請使用 Google Cloud 控制台。如果是單一預訂,請選取下列任一選項:
主控台
gcloud
如要刪除預留項目,請使用
gcloud compute reservations delete
指令:gcloud compute reservations delete RESERVATION_NAME \ --zone=ZONE
更改下列內容:
Go
Java
Node.js
Python
REST
如要刪除預留項目,請對
reservation.delete
方法發出DELETE
要求:DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME
更改下列內容:
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-15 (世界標準時間)。
-