
Gcloud
Let's go through a few commands to get a feel for the syntax of the gcloud CLI:
- To list all your projects, use:
$ gcloud projects list
- To list all your instances in the packt-gcp project, use:
$ gcloud compute instances list --project packt-gcp
The global generic syntax of the gcloud that also applies the other CLI tools is:
Where GROUP is a service or an account element and COMMAND is the command to send to the GROUP. For instance in gcloud projects list, projects is the GROUP, an element of your account and list is the COMMAND. In gcloud compute instances list --project packt-gcp, the GROUP is compute, followed by a sub-group instances, and the COMMAND is list while --project packt-gcp are the required parameters.
gcloud parameters include account settings (keys and region for instance), CLI settings (verbosity, format, or specific configuration) as well as arguments required by the commands. For example, to start our instance, we need to specify two parameters—the region and the instance ID: