To delete a gcloud instance template, we call
gcloud compute instance-templates delete TEMPLATE_NAME
But we have to answer a Y/n question which is not favored for automation bash script. We want auto answer yes, how?
p.s.
My google search for this question results little helpful.
Manual page of the command also has nothing about any other parameter.
gcloud help compute instance-templates delete
For example, to work with gcloud compute , type gcloud compute and then press F7 . You can then type subcommands such as list without needing to first type gcloud compute . When you're no longer using the command, press Ctrl-C and F7 to clear the context. To exit the interactive shell press Ctrl-D or F9 .
gcloud
has a set of global flags including --quiet
to disable such prompts:
https://cloud.google.com/sdk/gcloud/reference/
I agree that using --quiet
is the best way in the case of gcloud
commands.
But for a CLI tool that doesn't have such an option we can explicitly use printf
like below:
printf 'yes' | gcloud compute instance-templates delete TEMPLATE_NAME
I hope this is useful (if not in this case, then somewhere else).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With