本文將說明如何取消或刪除日後的預訂要求。
在未來預留要求達到鎖定時間之前,您可以執行下列任一操作,防止 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.
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 Future Reservation Admin (roles/compute.futureReservationAdmin
) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
這個預先定義的角色具備取消或刪除未來預訂要求所需的權限。如要查看確切的必要權限,請展開「必要權限」部分:
所需權限
如要取消或刪除未來預留項目要求,您必須具備下列權限:
-
如要取消未來預留項目,請按照下列步驟操作:
compute.futureReservations.cancel
在專案中 -
如要刪除未來預留項目,請按照下列步驟操作:
compute.futureReservations.delete
在專案上
取消未來的預留要求
你只能在下列情況下取消未來的預約:
要求處於待核准狀態,或已遭拒絕。
這項要求已獲核准,但尚未達到鎖定時間。
如要取消未來預訂要求,請選取下列任一選項:
gcloud
如要取消未來的預訂要求,請使用 gcloud beta compute future-reservations cancel
指令。
gcloud beta compute future-reservations cancel FUTURE_RESERVATION_NAME \
--zone=ZONE
更改下列內容:
FUTURE_RESERVATION_NAME
:現有未來預訂要求的名稱。ZONE
:未來預訂要求所在區域。
REST
如要取消未來預留要求,請對 beta.futureReservations.cancel
方法發出 POST
要求。
POST https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/futureReservations/FUTURE_RESERVATION_NAME/cancel
更改下列內容:
PROJECT_ID
:未來預訂要求所在專案的 ID。ZONE
:未來預訂要求所在區域。FUTURE_RESERVATION_NAME
:未來預訂要求的名稱。
刪除未來預留要求
您只能在下列情況下刪除未來預留要求:
這項要求尚未達到鎖定時間,且未處於待核准狀態。
要求已履行,且預訂期已結束。
如要刪除尚未核准的未來預訂要求,您必須先取消要求,再刪除。
刪除已完成的未來預留項目不會刪除自動建立的預留項目。如要在預留期間結束後刪除自動建立的預留項目,請參閱刪除預留項目。
如要同時刪除多個未來預留要求,請使用 Google Cloud 控制台。如要刪除單一未來預留要求,請選取下列任一選項:
主控台
在 Google Cloud 控制台,前往「Reservations」(預留項目) 頁面。
點按「Future reservations」(未來預留項目) 分頁標籤。
選取要刪除的所有未來預留要求。
按一下
「刪除預訂」。按一下「Delete」(刪除) 確認操作。
刪除未來預留項目要求最多需要一分鐘。
gcloud
如要刪除未來預留要求,請使用 gcloud beta compute future-reservations delete
指令。
gcloud beta compute future-reservations delete FUTURE_RESERVATION_NAME \
--zone=ZONE
更改下列內容:
FUTURE_RESERVATION_NAME
:現有未來預訂要求的名稱。ZONE
:未來預訂要求所在區域。
REST
如要刪除未來預留要求,請對 beta.futureReservations.delete
方法發出 DELETE
要求。
DELETE https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE/futureReservations/FUTURE_RESERVATION_NAME
更改下列內容:
PROJECT_ID
:未來預訂要求所在專案的 ID。ZONE
:未來預訂要求所在區域。FUTURE_RESERVATION_NAME
:現有未來預訂要求的名稱。
後續步驟
- 瞭解如何查看未來預留項目要求。