Delete a Compute Engine instance
Stay organized with collections
Save and categorize content based on your preferences.
This document explains how to delete a Compute Engine instance. To learn more
about the lifecycle of an instance, see
Compute Engine instance lifecycle.
If you no longer need an instance, then delete it to stop incurring charges for
the instance and its attached resources.
Before you begin
If you haven't already, set up authentication.
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:
To use the .NET 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.
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.
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.
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.
To use the PHP 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.
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.
To use the Ruby 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.
This predefined role contains
the permissions required to delete a compute instance. To see the exact permissions that are
required, expand the Required permissions section:
Required permissions
The following permissions are required to delete a compute instance:
compute.instances.delete
on the instance
To force the deletion of an attached disk:
compute.disks.delete
on the disk
In some cases, before you delete a compute instance, you might want to preserve
one of its attached resources. You can preserve attached resources by doing the
following:
If you've enabled
graceful shutdown in
the instance, then you can delete the instance without gracefully shutting
it down or end an ongoing graceful shutdown using the Google Cloud console,
gcloud CLI, or REST API.
To delete multiple instances simultaneously, use the Google Cloud console
or, for instances located in the same zone, the gcloud CLI.
To delete one or more instances and all attached resources, select one of the
following options:
By default, deleting a compute instance deletes the instance and its attached
resources. However, when you delete an instance using the gcloud CLI,
you can specify to preserve the attached disks, regardless of their
auto-delete settings.
To delete one or more instances in the same zone while preserving their attached
disks, use the
gcloud compute instances delete command
with the --keep-disks flag:
INSTANCE_NAMES: a list of instance names separated by
spaces—for example, instance-01 instance-02 instance-03.
KEEP_DISK_TYPE: specify one of the following values:
To preserve attached boot and non-boot persistent storage: all
To preserve only attached boot persistent storage: boot
To preserve only attached non-boot persistent storage: data
ZONE: the zone where the instances are located.
Optionally, if you've enabled
graceful shutdown in one
or more instances, you can delete the instances without gracefully shutting them
down, or manually end an ongoing graceful shutdown. To do so, use the
gcloud beta compute instances delete command
with the --no-graceful-shutdown flag:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-02 UTC."],[],[]]