This document explains how to delete reservations. To learn how to delete future reservation requests, see Cancel or delete future reservation requests instead.
Delete a reservation to stop incurring charges for reserved resources that you no longer need.
Limitations
Before you delete a reservation, consider the following:
You can only delete a shared reservation in the same project where you created it.
You can only delete a specifically targeted reservation if no Compute Engine instances consume it. If any instances consume the reservation, then, before you delete it, do one of the following:
You can only delete an auto-created reservation for a future reservation after its reservation period ends.
You can only delete a reservation that is attached to a commitment if you first detach it by replacing the reservation.
Before you begin
-
If you haven't already, then set up authentication.
Authentication is
the process by which your identity is verified 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:
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
-
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
- Set a default region and zone.
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.
-
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.
For more information, see Set up authentication for a local development environment.
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.
-
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.
For more information, see Set up authentication for a local development environment.
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.
-
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.
For more information, see Set up authentication for a local development environment.
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.
-
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.
For more information, see Set up authentication for a local development environment.
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, then initialize it by running the following command:
gcloud init
For more information, see Authenticate 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 the
Compute Admin (roles/compute.admin
) IAM role on the project.
For more information about granting roles, see Manage 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 with custom roles or other predefined roles.
Delete a reservation
If you delete a reservation that can be automatically consumed by any matching compute instances, then any instances that consume the deleted reservation keep running. You continue to incur charges for those instances.
You can delete single reservations or multiple reservations at once. For multiple reservations, use the Google Cloud console. For single reservations, select any of the following options:
In the Google Cloud console, go to the Reservations page.
On the On-demand reservations tab (default), select the reservations that you want to delete.
Click
Delete.To confirm, click Delete.
To delete a reservation, use the
gcloud compute reservations delete
command:
gcloud compute reservations delete RESERVATION_NAME \
--zone=ZONE
Replace the following:
RESERVATION_NAME
: the name of the reservation.ZONE
: the zone where the reservation exists.
To delete a reservation, make a DELETE
request to the
reservation.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 created the reservation.ZONE
: the zone where the reservation exists.RESERVATION_NAME
: the name of the reservation.
What's next
- Learn how to view your reservations.