Delete reservations

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:

Before you begin

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

  1. In the Google Cloud console, go to theReservations page.

    Go to Reservations

  2. On theOn-demand reservations tab (default), select the reservationsthat you want to delete.

  3. ClickDelete.

  4. To confirm, clickDelete.

gcloud

To delete a reservation, use thegcloud compute reservations delete command:

gcloud compute reservations deleteRESERVATION_NAME \    --zone=ZONE

Replace 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.DONEreturnoperation

REST

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_NAME

Replace 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

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.