arrow_back

Working with the Google Cloud Console and Cloud Shell (AWS)

Testez vos connaissances et partagez-les avec notre communauté
done
Accédez à plus de 700 ateliers pratiques, badges de compétence et cours

Working with the Google Cloud Console and Cloud Shell (AWS)

Atelier 40 minutes universal_currency_alt 5 crédits show_chart Débutant
info Cet atelier peut intégrer des outils d'IA pour vous accompagner dans votre apprentissage.
Testez vos connaissances et partagez-les avec notre communauté
done
Accédez à plus de 700 ateliers pratiques, badges de compétence et cours

As an IT professional who is familiar with AWS, you know that people within your organization have different ways of interacting with the AWS infrastructure based on their particular needs. Let’s do a high level overview of three ways you can interact with AWS infrastructure.

AWS Management Console The AWS Management Console is a web application that includes and refers to a broad collection of service consoles used to manage AWS resources. When you sign in, the console home page provides access to each service console and offers a single place to access the information you need to perform your AWS related tasks.

AWS CloudShell The AWS CloudShell is a browser-based, pre-authenticated shell launched directly from the AWS Management Console.

AWS Command Line Interface The AWS Command Line Interface (AWS CLI) is an open source tool enabling you to interact with AWS services using commands in your command-line shell. As with any CLI you can write your own scripts and automations to deploy and manage services and resources.

You set up IAM users with access to these tools in various ways depending upon their roles and how they will use the AWS resources:

  • For people in teams, such as development and testing, you create IAM users that can access AWS services and resources programmatically through the CLI client.
  • For users with AWS Management Console access, you only need to create a password.
  • For users with programmatic access where the IAM user might need to make API calls through the CLI Client, AWS tools for PowerShell, or the AWS tools for Linux, you need to create an Access Key Pair (Access Key ID and Secret Access Key).
  • You can also create IAM users with both levels of access or disable the key pair for a previously created user.

AWS Diagram

Let’s explore how you would interface with different options within Google Cloud to access its services and features.

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 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.

Qwiklabs setup

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

  1. Sign in to Qwiklabs using an incognito window.

  2. Note the lab's access time (for example, 1:15:00), and make sure you can finish within that time.
    There is no pause feature. You can restart if needed, but you have to start at the beginning.

  3. When ready, click Start lab.

  4. Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.

  5. Click Open Google Console.

  6. Click Use another account and copy/paste credentials for this lab into the prompts.
    If you use other credentials, you'll receive errors or incur charges.

  7. Accept the terms and skip the recovery resource page.

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 Cloud Console, on the Navigation menu (Navigation menu), click Cloud Storage > Bucket.
  2. Click Create.
  3. For Name, type a globally unique bucket name; leave all other values as their defaults.
  4. Click Create.

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
  • gsutil: 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 (Activate Cloud Shell icon). If prompted, click Continue. Cloud Shell opens at the bottom of the Cloud Console window.

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

    three icons on far right of Cloud Shell toolbar

    • Minimize/Restore: The first one minimizes or restores 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 gsutil 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):
gsutil mb gs://<BUCKET_NAME>
  1. If prompted, click Authorize.
  2. In the Cloud Console, on the Navigation menu (Navigation menu icon), click Cloud Storage > Bucket, 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 (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:
gsutil cp [MY_FILE] gs://[BUCKET_NAME]

If your filename has whitespaces, be sure to place single quotes around the filename. For example, gsutil 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.

Create and verify an environment variable

  1. Open Cloud Shell from the Cloud Console. Note that this allocates a new VM for you.

  2. Create an environment variable and replace [YOUR_REGION] with the region you selected in the previous step:

INFRACLASS_REGION={{{ project_0.default_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.
INFRACLASS_PROJECT_ID={{{project_0.project_id|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 gsutil.

You can install the Google Cloud SDK on a computer or on a VM instance in Google Cloud. The gcloud and gsutil 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

In this lab, you've explored the tools that you can use in Google Cloud. These tools manage the scripts that run your operations, as well as deploy and manage your resources programmatically similar to how you manage them in AWS.

In AWS, every action that you perform, either in the web interface or programmatically, is an API call. The AWS Management Console, the AWS CLI client, and the AWS CloudShell sessions sit on top of the API, allowing you to interact with your resources. Depending on the method that your users choose to interact with their AWS services, they will need different credentials:

  • To access the AWS Management Console, the user will need a password,
  • To use the AWS CLI, an Access Key pair is required.

In Google Cloud, you can interact in the same three ways by making use of the Cloud Console, the CLI Client or Cloud SDK, and the Cloud Shell. The CLI Client or Cloud SDK comes with several pre-built capabilities that will make your tasks easier, for example, the following:

  • gcloud: primary tool to set local configuration, manage Authentication Accessing, and access Google Cloud resources
  • bq: to create and manage BigQuery resources like datasets and queries
  • gsutil: to manage Cloud Storage and create, delete or list buckets, upload objects, and more

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.

Ce contenu n'est pas disponible pour le moment

We will notify you via email when it becomes available

Parfait !

We will contact you via email if it becomes available