Reputation: 741
I can't find the answer to this anywhere, but can you set "Enable delete protection" to VM instances in bulk in Google Cloud? Perhaps there is a CLI or plugin to do this? I can see that you can apply this to existing and for newly created instances, but we have hundreds of instances that will take time to do.
Regards
Upvotes: 0
Views: 316
Reputation: 1177
It is possible via CLI with a loop. An example for machines in the same zone would be:
for vm in gcloud compute instances list --format="csv('NAME')"; do
gcloud compute instances update $vm --zone=[ZONE] --deletion-protection;
done
You can easily extend it to work for multiple zones by getting NAME
and ZONE
from compute instances list
Upvotes: 3