Rich
Rich

Reputation: 12663

how to use gcloud to set disk deletion rule on an instance

As part of a startup script I use gcloud to create a disk from a snapshot:

gcloud compute disks create ...

and then attach it to the current instance

gcloud compute instances attach-disk `hostname` ...

I'd like to have this disk be deleted when the instance is deleted but I don't see the equivalent of "the "Delete Disk" Deletion rule see in the web console when editing an instance. How can I do this with a gcloud command?

how do delete disk rule with gcloud

Upvotes: 0

Views: 368

Answers (1)

Rich
Rich

Reputation: 12663

Found it right there in the docs: https://cloud.google.com/sdk/gcloud/reference/compute/instances/set-disk-auto-delete

Example:

gcloud compute instances set-disk-auto-delete `hostname` --disk=DISKNAME --zone=MY-ZONE

Upvotes: 2

Related Questions