Running gcloud commands with Cloud Shell

Cloud Shell comes with Cloud SDK pre-installed. This means you can run gcloud commands without additional setup. You can run gcloud command-line tool commands, like gcloud help straight away after activating a Cloud Shell session.

Additionally, any time you manage resources using the interactive interface from the Console, you can generate the equivalent gcloud command and run it in Cloud Shell. If you fill in the details of your required resource during tasks like the creation of an instance group or a Kubernetes cluster, the generated command will contain the correct flags and their values.

Example: Creating a Compute Engine instance with a generated gcloud command

  1. Go to the Compute Engine > VM instances page.
  2. Click Create.
  3. Fill in the required and optional fields to configure the new instance to suit your needs.
  4. Below the Create button, you'll find the option to generate the equivalent REST or gcloud command. Click on command line to see the suggested gcloud command. Viewing the equivalent gcloud command for a Compute Engine VM instance creation
  5. Click Run in Cloud Shell.
  6. Press Enter to execute the command once you see it at the prompt.
  7. Going back to the VM instances page, you'll see the newly created and running VM instance.
  8. Delete the instance either from the command line or the VM instances page, if you no longer need it, to avoid incurring unnecessary charges.