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)
Prerequisites
- Access to a GCP account
The integrated Cloud Shell in the console is really handy. But there will be times when it will be more convenient to have the SDK installed on a development or production machine. In this lesson, I am going to show you how to do just that.
You can find detailed installation instructions at https://cloud.google.com/sdk/docs/install. The actual steps will depend upon your operating system. The normal installation method is to download an installer, run it, and then follow the prompts. For some operating systems, there are alternative ways to install the SDK as well. You should pick the method that best suits your needs.
For this example, I will be following the instructions for Linux.
Next, you will want to verify that the installation was successful. You should be able to run “gcloud help” at the command prompt. If you get an error message, or if it says it could not find the command, then the SDK was not installed properly. You will need to refer back to the installation instructions, and figure out how to fix the issue.
If you get the help screen for the gcloud command, then you are ready to proceed. Next, run “gcloud init” to begin the setup process to authorize access to your account.
When asked if you would like to log in, type “Y” for yes. You will need to open the provided URL in a browser and sign in with Google. Then you will need to choose the account to log in with. Allow the Cloud SDK to manage GCP by clicking the “Allow” button. You will then be given a verification code that you need to copy and paste back in the terminal. Now pick a default project to use. You don’t need to set a default region or zone if you don’t wish to.
If you are behind a proxy, you might also need to perform a few extra steps to access GCP. Make sure to get your proxy settings from your network administrator, then follow the instructions here at https://cloud.google.com/sdk/docs/proxy-settings.
At this point the SDK should be installed and working properly. But before I end this lesson, I want to show you a couple more things that will help you in the future.
The SDK installs some components by default, but it also has optional components as well. You can enter “gcloud components list” to get a list of all components. You can also see which have been installed and which are available for install. For example, if you are going to be developing Java applications, you may want to install the Google App Engine Java component by entering: “gcloud components install app-engine-java”.
New components usually have dependencies, and so those will need to be installed first. Accept the dependencies by typing “Y”. Then you will just need to wait for installation to complete. Later, if you no longer have any use for a component, you can also use the “components remove” command to delete it.
Over time, all components will receive updates. To download and install these updates, you need to run the “components update” command. This command will go through all of your installed components and update any that have a newer version. It’s a good idea to run this command on a regular basis to ensure you have the latest features and fixes.
So now you should have enough knowledge to install and set up the SDK on your own computer. Remember to check out the online command references for “gcloud”, “gsutil” and maybe even “bq”. Don’t be afraid to experiment and get familiar with the various options.
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.