NOTE: This course has been updated. You can find the new version at https://cloudacademy.com/course/setting-up-google-cloud-platform-environment-1697
Google Cloud Platform (GCP) provides a suite of services that run on the same infrastructure that Google uses to host its own products, such as Google Search and YouTube. These services let you provision a variety of IT resources, such as virtual machines, storage, and networks.
GCP resources are grouped and deployed into projects. In this course, you will learn how to create and set up new GCP projects and how to give users permission to access project resources by assigning them to roles such as owner and editor.
Access to GCP services is provided via APIs that may be enabled on a per-project basis. You will learn how to enable APIs for a project as well as create budgets and configure monitoring for the resources and services allocated.
- Create new cloud projects
- Add users to projects and assign them to roles
- Enable GCP APIs and services for a project
- Provision Stackdriver accounts for monitoring project resources
- Add billing accounts and create project budgets
- Manage organization resources using the Cloud SDK
- People who would like to become GCP administrators
- People studying for the Google Associate Cloud Engineer exam
Finally, for our last section of this course, we will set up the Cloud SDK and run a few commands to manage our project locally. The Cloud SDK allows you to run commands in your terminal to interact with GCP services. These commands also allow you to create scripts that automate deployment and service configuration. Here, we will use the Cloud SDK to install components into our development environment, configure authentication, then set our default project.
The prerequisites for the Cloud SDK are Python 2.7 and Java if you're going to install Java tools for Google App Engine.
To download the Cloud SDK, navigate your browser to https://cloud.google.com/sdk. If you are on Windows, follow these instructions. Click the link to download the Cloud SDK Installer. Locate the installer in your Downloads folder or launch it from the Downloaded Files in your browser. Follow the installer prompts. Check "Start Google Cloud SDK Shell." Also, check "Run gcloud init" to configure the Cloud SDK. This will run gcloud init in the terminal window.
From here, the process for initializing the Cloud SDK is very similar on any operating system. I am on macOS, so I will demonstrate the full installation and gcloud init process on macOS.
For macOS and Linux, verify that you have Python. Open a terminal window. At the prompt, run python -v. If you do not have Python installed, install it before you continue. Download the installer for your version of macOS. Extract the downloaded archive, then open a terminal window in the archive folder. At the prompt, run install.sh. Then restart your shell to have the changes take effect.
To allow the Cloud SDK to access your projects, in your account, you must authorize it to do so. This authentication is very similar on any operating system.
Back at the command prompt, run gcloud init. When asked, "Would you like to log in?" type Y for yes. Your browser will open to sign in with Google. Choose an account to log in with. Allow the Cloud SDK to manage GCP by clicking the Allow button. Your browser will open. You are now authenticated with the Google Cloud SDK page. Go back to the command prompt. Choose the project to use. Now, the Cloud SDK is initialized and ready for use.
Many corporations run behind a proxy or a firewall. If you are behind a proxy or a firewall, you will need to configure the Cloud SDK with proxy settings to access GCP. Get the proxy settings from your network administrator. Once you have the proxy settings, configure the Cloud SDK to use the proxy. To configure the Cloud SDK to use a proxy, configure the proxy type in the terminal window by typing gcloud config set proxy type, then the proxy type. The proxy types supported are http, http_no_tunnel, socks4, and socks5. Configure the proxy IP address. Do this with gcloud config set proxy address, and then type in the proxy IP address.
To configure the proxy port, use gcloud config set proxy port, and type the proxy port. If your proxy requires a username and password, configure the proxy username with gcloud set proxy username, and type the username. Then configure the password with gcloud set proxy password and the password.
Now that our Cloud SDK is all set up, let's run some commands to see how this works. First, we will run the help command. This will give us a page instructing how to use the gcloud command and its many options. Open a terminal window and type gcloud --help. As you can see, this is a pretty comprehensive list. When learning, it is easier to read this online. Here is the URL for the gcloud reference (https://cloud.google.com/sdk/gcloud/reference).
Now, we will list the components available for install. We'll use gcloud components list. This command provides the list of components that have been installed and those that are available for install. Also, instructions for install and removal are given.
For example, I want to develop a Java application running on Google App Engine. To do this, we will use the install component command to install the Google App Engine Java component. We'll use gcloud components install app-engine-java.
Before components are installed, the list of dependencies and other components that will be installed in addition to the component we specified will be displayed. We will continue by typing Y for yes. The status of the install is printed, then it is done.
Over time, new versions of the components we have installed will have been released. To update our installed components, we run the update components command. This command will go through all of your installed components and update any that have newer versions. Later, if we have no use for app-engine-java, we can use the remove components command.
As developers, we often work with more than a single application on our workstations. This is where configurations come in. Suppose we are working with two different projects. We will create a configuration for each of them with different settings, then switch between them as needed. Configurations allow us to create settings for the individual projects we will work with. With a configuration, we can manage different projects with different settings.
Let's create a configuration for my-first-project named my-first-config. We will use gcloud config configurations create my-first-config. This will create and activate our configuration for my-first-config. Now, we will create a second configuration for our other project. This will create and activate our configuration for my-second-config. Now, I want to switch back to my-first-config. To do this, I will use the activate command.
To see the list of configurations we have added to our environment, we will use the config list command. Our configuration settings are displayed along with the active configuration name.
Now, let's set the default project for my-first-config to my-first-project. To do this, we will use the set project command. When we run the config list command again, we will see that we now have a default project configured. That's it.
Joseph Cava is a full-stack web development veteran, fluent in all levels of the architecture, specializing in agile software development, product development, user experience, database design, testing, and documentation, focused on cloud deployments to Google Cloud Platform, Amazon Web Services, and Microsoft Azure.