Deleting an Instance

This page describes how to delete an instance. If you don't want to delete an instance but want to temporarily stop it, read Stopping and Starting an Instance.

Delete an instance to remove the instance and the associated resources from your project. If the instance is part of an instance group, the group might try to recreate an identitcal instance to maintain a certain group size. Resize the instance group or reconfigure the autoscaler instead.

Before you begin

Delete an instance

Delete an instance using GCP Console, gcloud, or the API.

Console

  1. Go to the VM Instances page in the GCP Console.

    Go to the VM Instances page

  2. Check the instances you want to delete.
  3. Click the Delete button.

gcloud

Use the gcloud compute instances delete command. When you delete an instance in this way, the instance shuts down and is removed from the list of instances, and all resources attached to the instance are released, such as persistent disks and any static IP addresses.

To delete an instance, use the following command:

gcloud compute instances delete example-instance [example-instance-2 example-instance-3..]

API

Use the delete method:

DELETE https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-f/instances/example-instance

Shutdown period

When you stop or delete an instance, Compute Engine sends the ACPI Power Off signal to the instance and waits a short period of time for your instance to shut down cleanly. If your instance is still running after this grace period, Compute Engine forcefully terminates it even if your shutdown script is still running.

The length of the shutdown period depends on the type of your instance.

  • Normal instances have a shutdown period that usually lasts at least 90 seconds, but could be longer.
  • Preemptible instances have a shutdown period that lasts 30 seconds, which is the same length as the shutdown period that happens during the preemption process.

If you choose to run a shutdown script during this period, your shutdown script must finish running within this time period so that the operating system has time to complete its shutdown and flush buffers to disk.

What's next

Oliko tästä sivusta apua? Kerro mielipiteesi

Palautteen aihe:

Tämä sivu
Compute Engine Documentation