本文說明如何刪除預訂。如要瞭解如何刪除未來預留項目要求,請參閱取消或刪除未來預留項目要求。
刪除預留項目,停止為不再需要的預留資源付費。
限制
刪除預訂前,請考量以下事項:
您只能刪除建立共用保留項目的專案中的共用保留項目。
只有在沒有 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.
Go
To use the Go samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- 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.
For more information, see Set up authentication for a local development environment.
Java
To use the Java samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- 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.
For more information, see Set up authentication for a local development environment.
Node.js
To use the Node.js samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- 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.
For more information, see Set up authentication for a local development environment.
Python
To use the Python samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
- 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.
For more information, see Set up authentication for a local development environment.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the 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.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
必要的角色
如要取得刪除保留單所需的權限,請要求管理員為您授予專案的 Compute Admin (roles/compute.admin
) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
這個預先定義的角色包含 compute.reservations.delete
權限,這是刪除預訂項目所需的權限。
刪除預留項目
如果您刪除任何相符運算執行個體可自動使用的保留項目,則任何使用已刪除保留項目的執行個體都會繼續執行。您仍須支付這些執行個體的費用。
您可以刪除單一或多筆預訂。如果要進行多個預訂,請使用 Google Cloud 控制台。針對單一預訂,請選取下列任一選項:
主控台
在 Google Cloud 控制台,前往「Reservations」(預留項目) 頁面。
在「On-demand reservations」分頁 (預設) 中,選取要刪除的預留項目。
按一下
「刪除」。按一下「Delete」(刪除) 確認操作。
gcloud
如要刪除保留項目,請使用 gcloud compute reservations delete
指令:
gcloud compute reservations delete RESERVATION_NAME \
--zone=ZONE
更改下列內容:
RESERVATION_NAME
:保留項目的名稱。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
更改下列內容:
PROJECT_ID
:您建立預訂項目的專案 ID。ZONE
:預訂項目所在區域。RESERVATION_NAME
:保留項目的名稱。
後續步驟
- 瞭解如何查看預訂資訊。