Search code examples
google-cloud-platformgoogle-compute-enginegoogle-cloud-billing

GCP Delete Compute Engine - VM Instances - without enabling the billing


I have a situation to delete lot of VMs which was created in my GCP Project. But I need to delete all those VMs before I enable the billing.

Is this possible?

I tried with Cloud Shell, but No luck as the VM are Delete protection enabled.


Solution

  • You can use the Cloud Console, Cloud Shell or GCP API to disable the Delete Protection first.

    For Cloud Console, just go to Compute Engine > VM Instance > Click the instance to be edited > Click Edit > Uncheck "Enable Deletion Protection".

    But for multiple VM's it is advisable to use the cloud shell instead. See the template below:

    gcloud compute instances update [INSTANCE_NAME]
    [--deletion-protection | --no-deletion-protection]

    For example:

    gcloud compute instances update vm-instance1 --no-deletion-protection

    For more information about this topic, you can check this link. Toggling deletion protection