arrow_back

Working with the Google Cloud Console and Cloud Shell

Sign in Join
Get access to 700+ labs and courses

Working with the Google Cloud Console and Cloud Shell

Lab 40 minutes universal_currency_alt 5 Credits show_chart Introductory
info This lab may incorporate AI tools to support your learning.
Get access to 700+ labs and courses

Overview

In this lab, you become familiar with the Google Cloud web-based interface. There are two integrated environments: a GUI (graphical user interface) environment called the Google Cloud console, and a CLI (command-line interface) called Cloud Shell. In this lab, you use both environments.

Here are a few things you need to know about the Cloud console:

  • The Cloud console is under continuous development, so occasionally the graphical layout changes. This is most often to accommodate new Google Cloud features or changes in the technology, resulting in a slightly different workflow.
  • You can perform most common Google Cloud actions in the Cloud console, but not all actions. In particular, very new technologies or sometimes detailed API or command options are not implemented (or not yet implemented) in the Cloud console. In these cases, the command line or the API is the best alternative.
  • The Cloud console is extremely fast for some activities. The Cloud console can perform multiple actions on your behalf that might require many CLI commands. It can also perform repetitive actions. In a few clicks you can accomplish activities that would require a lot of typing and would be susceptible to typing errors.
  • The Cloud console is able to reduce errors by offering only valid options through its menus. It can leverage access to the platform "behind the scenes" through the SDK to validate configuration before submitting changes. A command line can't do this kind of dynamic validation.

Objectives

In this lab, you learn how to perform the following tasks:

  • Get access to Google Cloud.
  • Use the Cloud console to create a Cloud Storage bucket.
  • Use Cloud Shell to create a Cloud Storage bucket.
  • Become familiar with Cloud Shell features.

Setup and Requirements

For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Cloud console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).

    The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab Details panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab Details panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To view a menu with a list of Google Cloud products and services, click the Navigation menu at the top-left, or type the service or product name in the Search field.

Task 1. Use the Cloud console to create a bucket

In this task, you create a bucket. However, the text also helps you become familiar with how actions are presented in the lab instructions in this class and teaches you about the Cloud console interface.

Navigate to the Storage service and create the bucket

  1. In the Google Cloud console, on the Navigation menu (), click Cloud Storage > Buckets.
  2. Click Create.
  3. For Name, type a globally unique bucket name; leave all other values as their defaults.
  4. Click Create.
  5. If prompted Public access will be prevented click Confirm.

Explore features in the Cloud console

The Google Cloud menu contains a Notifications icon. Sometimes, feedback from the underlying commands is provided there. If you are not sure what is happening, check Notifications for additional information and history.

Click Check my progress to verify the objective.

Create a bucket using the Cloud console

Task 2. Access Cloud Shell

In this section, you explore Cloud Shell and some of its features.

You can use the Cloud Shell to manage projects and resources via command line without having to install the Cloud SDK and other tools on your computer.

Cloud shell provides the following:

  • Temporary Compute Engine VM
  • Command-line access to the instance via a browser
  • 5 GB of persistent disk storage ($HOME dir)
  • Pre-installed Cloud SDK and other tools
  • gcloud: for working with Compute Engine and many Google Cloud services
  • gcloud storage: for working with Cloud Storage
  • kubectl: for working with Google Kubernetes Engine and Kubernetes
  • bq: for working with BigQuery
  • Language support for Java, Go, Python, Node.js, PHP, and Ruby
  • Web preview functionality
  • Built-in authorization for access to resources and instances

Learn more about Cloud Shell from the Google Cloud Cloud Shell Documentation.

Note: After 1 hour of inactivity, the Cloud Shell instance is recycled. Only the /home directory persists. Any changes made to the system configuration, including environment variables, are lost between sessions.

Open Cloud Shell and explore features

  1. In the Google Cloud menu, click Activate Cloud Shell (). If prompted, click Continue. Cloud Shell opens at the bottom of the Cloud console window.

    There are four buttons on the far right of the Cloud Shell toolbar:

    • Minimize The first button minimizes the window.
    • Restore/Maximize: The next button restores the window if minimized, or maximizes the window, giving you full access to the Cloud console without closing Cloud Shell.
    • Open in a new window: Having Cloud Shell at the bottom of the Cloud console is useful when you are issuing individual commands. However, sometimes you will be editing files or want to see the full output of a command. For these uses, this button pops the Cloud Shell out into a full-sized terminal window.
    • Close terminal: This button closes Cloud Shell. Every time you close Cloud Shell, the virtual machine is reset and all machine context is lost.
  2. Close Cloud Shell now.

Task 3. Use Cloud Shell to create a Cloud Storage bucket

Create a second bucket and verify in the Cloud console

  1. Open Cloud Shell again.
  2. Use the gcloud storage command to create another bucket. Replace [BUCKET_NAME] with a globally unique name (you can append a 2 to the globally unique bucket name you used previously):
gcloud storage buckets create gs://[BUCKET_NAME]
  1. If prompted, click Authorize.
  2. In the Google Cloud console, on the Navigation menu (), click Cloud Storage > Buckets, or click Refresh if you are already in the Storage browser. The second bucket should be displayed in the Buckets list.
Note: You have performed equivalent actions using the Cloud console and Cloud Shell. You created a bucket using the Cloud console and another bucket using Cloud Shell.

Click Check my progress to verify the objective.

Create a bucket using Cloud Shell

Task 4. Explore more Cloud Shell features

Upload a file

  1. Open Cloud Shell.
  2. Click the More button () in the Cloud Shell toolbar to display further options.
  3. Click Upload. Upload any file from your local machine to the Cloud Shell VM. This file will be referred to as [MY_FILE].
  4. In Cloud Shell, type ls to confirm that the file was uploaded.
  5. Copy the file into one of the buckets you created earlier in the lab. Replace [MY_FILE] with the file you uploaded and [BUCKET_NAME] with one of your bucket names:
gcloud storage cp [MY_FILE] gs://[BUCKET_NAME]

If your filename has whitespaces, be sure to place single quotes around the filename. For example, gcloud storage cp ‘my file.txt' gs://[BUCKET_NAME]

Note: You have uploaded a file to the Cloud Shell VM and copied it to a bucket.
  1. Explore the options available in Cloud Shell by clicking on different icons in the Cloud Shell toolbar.
  2. Close all the Cloud Shell sessions.

Click Check my progress to verify the objective.

Upload a file to Storage bucket

Task 5. Create a persistent state in Cloud Shell

In this section you will learn a best practice for using Cloud Shell. The gcloud command often requires you to specify values such as a Region, Zone, or Project ID. Entering them repeatedly increases the chance of making typing errors. If you use Cloud Shell frequently, you may want to set common values in environment variables and use them instead of typing the actual values.

Identify available regions

  1. Open Cloud Shell from the Google Cloud console. Note that this allocates a new VM for you.
  2. To list available regions, execute the following command:
gcloud compute regions list
  1. Select a region from the list and note the value in any text editor. This region will now be referred to as [YOUR_REGION] in the remainder of the lab.

Create and verify an environment variable

  1. Create an environment variable and replace [YOUR_REGION] with the region you selected in the previous step:
INFRACLASS_REGION=[YOUR_REGION]
  1. Verify it with echo:
echo $INFRACLASS_REGION

You can use environment variables like this in gcloud commands to reduce the opportunities for typos and so that you won't have to remember a lot of detailed information.

Note: Every time you close Cloud Shell and reopen it, a new VM is allocated, and the environment variable you just set disappears. In the next steps, you create a file to set the value so that you won't have to enter the command each time Cloud Shell is reset.

Append the environment variable to a file

  1. Create a subdirectory for materials used in this lab:
mkdir infraclass
  1. Create a file called config in the infraclass directory:
touch infraclass/config
  1. Append the value of your Region environment variable to the config file:
echo INFRACLASS_REGION=$INFRACLASS_REGION >> ~/infraclass/config
  1. Create a second environment variable for your Project ID, replacing [YOUR_PROJECT_ID] with your Project ID. You can find the project ID on the Cloud console Home page.
INFRACLASS_PROJECT_ID=[YOUR_PROJECT_ID]
  1. Append the value of your Project ID environment variable to the config file:
echo INFRACLASS_PROJECT_ID=$INFRACLASS_PROJECT_ID >> ~/infraclass/config
  1. Use the source command to set the environment variables, and use the echo command to verify that the project variable was set:
source infraclass/config echo $INFRACLASS_PROJECT_ID Note: This gives you a method to create environment variables and to easily recreate them if the Cloud Shell is recycled or reset. However, you will still need to remember to issue the source command each time Cloud Shell is opened. In the next step, you modify the .profile file so that the source command is issued automatically every time a terminal to Cloud Shell is opened.
  1. Close and re-open Cloud Shell. Then issue the echo command again:
echo $INFRACLASS_PROJECT_ID

There will be no output because the environment variable no longer exists.

Modify the bash profile and create persistence

  1. Edit the shell profile with the following command:
nano .profile
  1. Add the following line to the end of the file:
source infraclass/config
  1. Press Ctrl+O, ENTER to save the file, and then press Ctrl+X to exit nano.
  2. Close and then re-open Cloud Shell to reset the VM.
  3. Use the echo command to verify that the variable is still set:
echo $INFRACLASS_PROJECT_ID

You should now see the expected value that you set in the config file.

Note: If your Cloud Shell environment is ever corrupted, instructions on resetting it are in the Cloud Shell Documentation article titled Disabling or Resetting Cloud Shell. This will cause everything in your Cloud Shell environment to be set back to its original default state.

Task 6. Review the Google Cloud interface

Cloud Shell is an excellent interactive environment for exploring Google Cloud by using Google Cloud SDK commands like gcloud and gcloud storage.

You can install the Google Cloud SDK on a computer or on a VM instance in Google Cloud. The gcloud and gcloud storage commands can be automated by using a scripting language like bash (Linux) or Powershell (Windows). You can also explore using the command-line tools in Cloud Shell, and then use the parameters as an implementation guide in the SDK using one of the supported languages.

The Google Cloud interface consists of two parts: the Cloud console and Cloud Shell.

The console:

  • Provides a fast way to perform tasks.
  • Presents options to you, instead of requiring you to know them.
  • Performs behind-the-scenes validation before submitting the commands.

Cloud Shell provides:

  • Detailed control
  • A complete range of options and features
  • A path to automation through scripting

End your lab

When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.

You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.

The number of stars indicates the following:

  • 1 star = Very dissatisfied
  • 2 stars = Dissatisfied
  • 3 stars = Neutral
  • 4 stars = Satisfied
  • 5 stars = Very satisfied

You can close the dialog box if you don't want to provide feedback.

For feedback, suggestions, or corrections, please use the Support tab.

Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

This content is not currently available

We will notify you via email when it becomes available

Great!

We will contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.