Delete reservations Stay organized with collections Save and categorize content based on your preferences.
This document explains how to delete reservations. To learn how to delete futurereservation requests, seeCancel or delete future reservation requestsinstead.
Delete a reservation to stop incurring charges for reserved resources that youno longer need.
Limitations
Before you delete a reservation, consider the following:
You can only delete a shared reservation in the same project where youcreated it.
You can only delete aspecifically targeted reservationif no Compute Engine instances consume it. If any instances consume thereservation, then, before you delete it, do one of the following:
You can only delete an auto-created reservation for a future reservationafter its reservation period ends.
You can only delete a reservation that is attached to a commitment if youfirst detach it byreplacing the reservation.
Before you begin
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
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
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- 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.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
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.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
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.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
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.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
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.
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.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
Required roles
To get the permission that you need to delete reservations, ask your administrator to grant you theCompute Admin (roles/compute.admin) IAM role on the project. For more information about granting roles, seeManage access to projects, folders, and organizations.
This predefined role contains the compute.reservations.delete permission, which is required to delete reservations.
You might also be able to get this permission withcustom roles or otherpredefined roles.
Delete a reservation
If you delete a reservation that can be automatically consumed by any matchingcompute instances, then any instances that consume the deleted reservation keeprunning. You continue to incur charges for those instances.
You can delete single reservations or multiple reservations at once. Formultiple reservations, use the Google Cloud console. For single reservations, selectany of the following options:
Console
In the Google Cloud console, go to theReservations page.
On theOn-demand reservations tab (default), select the reservationsthat you want to delete.
ClickDelete.
To confirm, clickDelete.
gcloud
To delete a reservation, use thegcloud compute reservations delete command:
gcloud compute reservations deleteRESERVATION_NAME \ --zone=ZONEReplace the following:
RESERVATION_NAME: the name of the reservation.ZONE: the zone where the reservation exists.
Go
import("context""fmt""io"compute"cloud.google.com/go/compute/apiv1"computepb"cloud.google.com/go/compute/apiv1/computepb")// Deletes the reservation for given project and zonefuncdeleteReservation(wio.Writer,projectID,zone,reservationNamestring)error{// projectID := "your_project_id"// zone := "us-west3-a"// reservationName := "your_reservation_name"ctx:=context.Background()reservationsClient,err:=compute.NewReservationsRESTClient(ctx)iferr!=nil{returnerr}deferreservationsClient.Close()req:=&computepb.DeleteReservationRequest{Project:projectID,Reservation:reservationName,Zone:zone,}op,err:=reservationsClient.Delete(ctx,req)iferr!=nil{returnfmt.Errorf("unable to delete reservation: %w",err)}iferr=op.Wait(ctx);err!=nil{returnfmt.Errorf("unable to wait for the operation: %w",err)}fmt.Fprintf(w,"Reservation deleted\n")returnnil}Java
importcom.google.cloud.compute.v1.DeleteReservationRequest;importcom.google.cloud.compute.v1.Operation;importcom.google.cloud.compute.v1.ReservationsClient;importjava.io.IOException;importjava.util.concurrent.ExecutionException;importjava.util.concurrent.TimeUnit;importjava.util.concurrent.TimeoutException;publicclassDeleteReservation{publicstaticvoidmain(String[]args)throwsIOException,ExecutionException,InterruptedException,TimeoutException{// TODO(developer): Replace these variables before running the sample.// Project ID or project number of the Cloud project you want to use.StringprojectId="YOUR_PROJECT_ID";// Name of the reservation you want to delete.StringreservationName="YOUR_RESERVATION_NAME";// Name of the zone.Stringzone="us-central1-a";deleteReservation(projectId,zone,reservationName);}// Delete a reservation from the project.publicstaticvoiddeleteReservation(StringprojectId,Stringzone,StringreservationName)throwsIOException,ExecutionException,InterruptedException,TimeoutException{/* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. */try(ReservationsClientreservationsClient=ReservationsClient.create()){DeleteReservationRequestdeleteReservationRequest=DeleteReservationRequest.newBuilder().setProject(projectId).setZone(zone).setReservation(reservationName).build();Operationresponse=reservationsClient.deleteAsync(deleteReservationRequest).get(5,TimeUnit.MINUTES);if(response.getStatus()==Operation.Status.DONE){System.out.println("Deleted reservation: "+reservationName);}}}}Node.js
// Import the Compute libraryconstcomputeLib=require('@google-cloud/compute');// Instantiate a reservationsClientconstreservationsClient=newcomputeLib.ReservationsClient();// Instantiate a zoneOperationsClientconstzoneOperationsClient=newcomputeLib.ZoneOperationsClient();/** * TODO(developer): Update/uncomment these variables before running the sample. */// The ID of the project where your reservation is located.constprojectId=awaitreservationsClient.getProjectId();// The zone where your reservation is located.constzone='us-central1-a';// The name of the reservation to delete.// reservationName = 'reservation-01';asyncfunctioncallDeleteReservation(){// Delete the reservationconst[response]=awaitreservationsClient.delete({project:projectId,reservation:reservationName,zone,});letoperation=response.latestResponse;// Wait for the delete reservation operation to complete.while(operation.status!=='DONE'){[operation]=awaitzoneOperationsClient.wait({operation:operation.name,project:projectId,zone:operation.zone.split('/').pop(),});}console.log(`Reservation:${reservationName} deleted.`);}awaitcallDeleteReservation();Python
from__future__importannotationsimportsysfromtypingimportAnyfromgoogle.api_core.extended_operationimportExtendedOperationfromgoogle.cloudimportcompute_v1defwait_for_extended_operation(operation:ExtendedOperation,verbose_name:str="operation",timeout:int=300)->Any:""" Waits for the extended (long-running) operation to complete. If the operation is successful, it will return its result. If the operation ends with an error, an exception will be raised. If there were any warnings during the execution of the operation they will be printed to sys.stderr. Args: operation: a long-running operation you want to wait on. verbose_name: (optional) a more verbose name of the operation, used only during error and warning reporting. timeout: how long (in seconds) to wait for operation to finish. If None, wait indefinitely. Returns: Whatever the operation.result() returns. Raises: This method will raise the exception received from `operation.exception()` or RuntimeError if there is no exception set, but there is an `error_code` set for the `operation`. In case of an operation taking longer than `timeout` seconds to complete, a `concurrent.futures.TimeoutError` will be raised. """result=operation.result(timeout=timeout)ifoperation.error_code:print(f"Error during{verbose_name}: [Code:{operation.error_code}]:{operation.error_message}",file=sys.stderr,flush=True,)print(f"Operation ID:{operation.name}",file=sys.stderr,flush=True)raiseoperation.exception()orRuntimeError(operation.error_message)ifoperation.warnings:print(f"Warnings during{verbose_name}:\n",file=sys.stderr,flush=True)forwarninginoperation.warnings:print(f" -{warning.code}:{warning.message}",file=sys.stderr,flush=True)returnresultdefdelete_compute_reservation(project_id:str,zone:str="us-central1-a",reservation_name="your-reservation-name",)->ExtendedOperation:""" Deletes a compute reservation in Google Cloud. Args: project_id (str): The ID of the Google Cloud project. zone (str): The zone of the reservation. reservation_name (str): The name of the reservation to delete. Returns: The operation response from the reservation deletion request. """client=compute_v1.ReservationsClient()operation=client.delete(project=project_id,zone=zone,reservation=reservation_name,)wait_for_extended_operation(operation,"Reservation deletion")print(operation.status)# Example response:# Status.DONEreturnoperationREST
To delete a reservation, make aDELETE request to thereservation.delete method:
DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAMEReplace the following:
PROJECT_ID: the ID of the project where you createdthe reservation.ZONE: the zone where the reservation exists.RESERVATION_NAME: the name of the reservation.
What's next
- Learn how toview your reservations.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.