Using Google Cloud SDK


Intro to Google Cloud SDK
Using Google Cloud SDK

The Google Cloud Software Development Kit includes language-specific client and API libraries you can use to interface with your Google Cloud account. One of the most helpful features is the command line interface which makes it easy to perform many common cloud tasks, either manually or by scripting.

Learning Objectives

  • Install and configure the Google Cloud SDK
  • Be familiar with basic use cases for the SDK
  • Install and update components
  • Create and manage configurations 

Intended Audience

  • GCP Developers
  • People who want to get GCP certified (e.g. Associate Cloud Engineer)


  • Access to a GCP account

The Google Cloud Console provides you an easy way to manage your account and make changes.  However, this is not your only option.  The Cloud Software Development Kit (or Cloud SDK) allows you to interact with your GCP account by running commands in a terminal.  You can accomplish tasks that would otherwise take you multiple steps with just one command.  Also, you can use the Cloud SDK to create custom scripts or programs to automate repeatable tasks such as deployments.

Before I cover installation and set up, let me first show what you can do with the Cloud SDK by using Cloud Shell.  Cloud Shell is an online terminal built right into the console. It already has the Cloud SDK preinstalled and preconfigured.  So if you have a GCP account, you can jump right in and start using it.

To access the Cloud Shell, login to the GCP console, and then click the icon in the top right part of the page labeled “Activate Cloud Shell”.  It might take a little while to load if you are opening it up for the first time.  To make things easier for you to see, let me open the Cloud Shell in it’s own tab, by clicking here.

The Cloud SDK provides several commands that allow you to interact with various services. 

  • The first one is called GCLOUD
    • This is the main utility for performing common cloud tasks, including:
      • Installing and upgrading components
      • Spinning up Compute Engine instances
      • Deploying apps to App Engine
  • The second one is called GSUTIL
    • GSUTIL stands for “Google Storage Utility”
    • This is used for interacting with Google Storage such as managing Cloud Storage buckets and objects
  • And the third is simply called BQ
    • This is used for interacting with BigQuery, so you would use it for things like running queries and manipulating datasets

Now, let me show you a few examples of what you can do with the SDK.

First, you can use it to get basic information about your account.  If you type “gcloud projects list” , you can list out all your current projects.  You can use “gcloud projects get-aim-policy” to find all the IAM users for a specific project

The SDK can do a lot more than just pull information.  You can also use it to provision new resources.  If you want to create a new Compute Engine instance by using the console, you will need to navigate to the correct screen.  And then fill out a long form like this.  You would enter a name, select a region, pick a machine type, and a bunch of other settings.  Now this is fine if you only need to do this occasionally.  But what if you need to start up many VMs per day?  Or what if you need to be able to create a script to start up VMs for you?  

For that, you will need the Command line equivalent.  Which you can actually get if you click on the button labeled “command line” at the bottom of the screen here.  This will take all the settings you selected and generate the equivalent terminal command.  Now you can copy and paste this into the terminal.  Or you could use it to create a script or just save it for later.  You also can easily modify any of these options, if you want something a little different.  Like changing the boot disk size to 50 GB instead of 10.  The gcloud command can create Compute Engine instances, GKE clusters, firewall rules, and much, much more.

One of the problems with using the command line is that you often have to pass in a lot of options.  This gets repetitive if you tend to work on the same project.  So it also provides a way to set certain values such as the default project and default zone.

And because you might need to work on multiple projects, you can even create multiple configurations and switch between them.  So you can create one config for one project like this.  And then another configuration for your second project.

You can see that I now have two new configurations.  I can select the configuration I want, and then set the project and zone for that config.  I could also switch to the second config and set a different project and zone.  There are other settings you add as well.  But this makes it easy for you to work on multiple projects without having to manually enter the same values over and over again.  It will also help you from getting confused and deploying resources for a project into the wrong region or zone.

This was just a small taste of what the SDK can do.  For a full list of options, refer to the following URLs:

About the Author
Learning Paths

Daniel began his career as a Software Engineer, focusing mostly on web and mobile development. After twenty years of dealing with insufficient training and fragmented documentation, he decided to use his extensive experience to help the next generation of engineers.

Daniel has spent his most recent years designing and running technical classes for both Amazon and Microsoft. Today at Cloud Academy, he is working on building out an extensive Google Cloud training library.

When he isn’t working or tinkering in his home lab, Daniel enjoys BBQing, target shooting, and watching classic movies.