Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Platform delete or stop instances without prompt

I can use Google compute api to start instances with no problem. I am actually using a script for some light auto-scaling. I boot these instances from a snapshot successfully with no block. However, deleting the instances asks me for confirmation.

gcloud compute instances delete ... 

The following instances will be deleted. Attached disks configured to be auto-deleted will be deleted unless they are attached to any other instances. Deleting a disk is irreversible and any data on the disk will be lost. - [xxx-client-1] in [us-central1-f] - [xxx-client-2] in [us-central1-f] - [xxx-client-3] in [us-central1-f]

Do you want to continue (Y/n)? Y

I want to delete without prompt.


I would be ok with stopping the instances, but this seems to fail:

gcloud compute instances stop ... 

ERROR: (gcloud.compute.instances) Invalid choice: 'stop'. Did you mean 'list'?

Has 'stop' been changed?

like image 394
user3480774 Avatar asked Mar 09 '16 19:03

user3480774


People also ask

How do I stop instances on Google Cloud?

To stop a VM, use the Google Cloud console, the gcloud CLI, or the Compute Engine API. In the console, go to the VM instances page. Select one or more VMs that you want to stop. Click Stop.

Does Google Cloud charge for stopped instances?

A stopped instance does not incur charges, but all of the resources that are attached to the instance will still be charged. For example, you are charged for persistent disks and external IP addresses according to the price sheet, even if an instance is stopped.

How do I reset my Google Cloud instance?

If you would like to completely reset an instance to it's original, unmodified state, the most efficient method would be to simply create a new instance of the same specification (i.e. by selecting the same source image and machine settings), and then to delete the old/modified one.


1 Answers

Specify --quiet or -q on your delete command. This will disable prompts (and assume defaults). gcloud help describes this and other gcloud flag options available on all commands.

Regarding 'stop', what version of gcloud are you using (you can run gcloud --version to find out)? Sounds like your gcloud client is old.

like image 93
kevan Avatar answered Sep 26 '22 03:09

kevan