32
votes

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?

1
Have you tried using managed instance groups? cloud.google.com/compute/docs/instance-groups They have a target size and resize operation to automate most of what you are doing here manually....Grzenio

1 Answers

52
votes

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.