Create a Compute Engine Virtual Machine Instance

Vérifier ma progression

/ 30

Install software and configure the VM instance

Vérifier ma progression

/ 30

Run application software to get success response

Vérifier ma progression

/ 40

Cet atelier peut intégrer des outils d'IA pour vous accompagner dans votre apprentissage.
Ce contenu n'est pas encore optimisé pour les appareils mobiles.
Pour une expérience optimale, veuillez accéder à notre site sur un ordinateur de bureau en utilisant un lien envoyé par e-mail.

GSP183

Google Cloud self-paced labs

Overview

In this lab, you set up a Python development environment on Google Cloud using Compute Engine to create a virtual machine (VM) instance and install software libraries for software development.

Objectives

In this lab, you learn how to:

  • Provision a Compute Engine instance.
  • Connect to the instance using SSH.
  • Install a Python library and development dependencies on the instance.
  • Verify the software installation by running a sample Python application.

Google Cloud

Google Cloud consists of a set of physical assets, such as computers and hard disk drives, and virtual resources, such as virtual machines (VMs), that are contained in Google's data centers around the globe. Each data center location is in a global region. Regions include Central US, Western Europe, and East Asia. Each region is a collection of zones, which are isolated from each other within the region. Each zone is identified by a name that combines a letter identifier with the name of the region. For example, zone a in the East Asia region is named asia-east1-a.

This distribution of resources provides several benefits, including redundancy in case of failure and reduced latency by locating resources closer to clients. This distribution also introduces some rules about how resources can be used together.

Projects

Any Google Cloud resources that you allocate and use must belong to a project. You can think of a project as the organizing entity for what you're building.

A project is made up of the settings, permissions, and other metadata that describe your applications.

Resources within a single project can work together easily, for example by communicating through an internal network, subject to the regions-and-zones rules. The resources that each project contains remain separate across project boundaries; you can only interconnect them through an external network connection.

Each Google Cloud project has a:

  • Project name: A human-readable name that you provide.
  • Project ID: A unique identifier that you can choose or Google Cloud assigns for you.
  • Project number: A globally unique number assigned by Google Cloud.

As you work with Google Cloud, you'll use these identifiers in certain command lines and API calls.

For example:

  • Example Project is the project name.
  • example-id is the project ID.
  • 123456789012 is the project number.

Each project ID is unique across Google Cloud. After you create a project, you can delete the project, but its ID can never be used again.

When billing is enabled, each project is associated with one billing account. Multiple projects can have their resource usage billed to the same account.

A project serves as a namespace. This means every resource within each project must have a unique name, but you can usually reuse resource names if they are in separate projects. Some resource names must be globally unique. Refer to the documentation for the resource for details.

Ways to interact with the services

Google Cloud gives you three basic ways to interact with services and resources:

  • Google Cloud console: A web-based graphical user interface to manage your Google Cloud projects and resources.
  • Command-line interface:
    • Google Cloud SDK/gcloud CLI: A command-line tool to manage your development workflow and Google Cloud resources.
    • Cloud Shell: A browser-based, interactive shell environment for Google Cloud accessible directly from the Google Cloud console.
  • Client libraries: Libraries that enable you to easily create and manage resources programmatically using your preferred programming language APIs.

Setup

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.

This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

How to start your lab and sign in to the Google Cloud console

  1. Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:

    • The Open Google Cloud console button
    • The temporary credentials (username and password) that you must use for this lab
    • Other information, if needed, to step through this lab

    Note that the lab timer is located near the top of the page, showing the remaining time.

  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 setup and access 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 setup and access 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 access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field. Navigation menu icon and Search field

Task 1. Create a Compute Engine virtual machine instance

In this section, you use the Google Cloud console to provision a new Compute Engine virtual machine (VM) instance.

Create and connect to a virtual machine

  1. In the Google Cloud console, on the Navigation menu (Navigation menu icon), click Compute Engine > VM instances.

  2. Click Create instance.

  3. In the Machine configuration section, specify the following values:

    Property Value (type value or select option as specified)
    Name dev-instance
    Region
    Zone
    Series E2
Note: Regions and zones

Google Cloud offers products and services in multiple distinct geographic locations, called regions. Each region has multiple distinct zones. Each zone is isolated from other zones in terms of power and internet connectivity.
  1. In the OS and storage (Boot disk) section, click Change to configure your boot disk and select the following values:

    • Operating system: Debian
    • Version:

    Click Select.

Note: If there are multiple options for the same Debian version (e.g., x86/64 and arm64), select the x86/64 version. ARM-based images are not compatible with the E2 machine types used in this lab.
  1. In the Networking section, under Firewalls, select:

    • Allow HTTP traffic
  2. In the Security (Identity and API access) section, under Access scopes, select:

    • Allow full access to all Cloud APIs
  3. Leave the remaining settings at their default values, and click Create.

Note: It takes about 20 seconds for the VM to be provisioned and started.

Test completed task

Click Check my progress to verify your performed task. If you have completed the task successfully, you will receive an assessment score.

Create a Compute Engine Virtual Machine Instance
  1. On the VM instances page, in the dev-instance row, click SSH.

This launches a browser-hosted SSH session. If you have a popup blocker enabled, you might need to click twice.

There is no need to manually configure or manage SSH keys.

Install software on the VM instance

  1. In the SSH session, to update the Debian package list, execute the following command:

    sudo apt-get update
  2. To install Git (as part of standard developer workstation tooling), execute the following command:

    sudo apt-get install git -y
  3. To install Python and build dependencies, execute the following command:

    sudo apt-get install python3-setuptools python3-dev build-essential -y
  4. To install pip, execute the following commands:

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py sudo python3 get-pip.py --break-system-packages

Test completed task

Click Check my progress to verify your performed task. If you have completed the task successfully, you will receive an assessment score.

Install software and configure the VM instance

Task 2. Configure the VM to run application software

In this section, you verify the software installation on your VM and run sample Python code.

Verify Python installation

  1. In the SSH terminal window, verify the installation by checking the Python and pip versions:

    python3 --version pip3 --version

    The output displays the installed versions of Python and pip.

  2. Download the lab assets:

    gcloud storage cp -r gs://{{{project_0.startup_script.assets_bucket|PROJECT_ID-assets}}}/devenv .
  3. Change the working directory:

    cd devenv
  4. Run a simple web server:

    sudo python3 server.py
  5. Return to the Google Cloud console VM instances page (Navigation menu > Compute Engine > VM instances), and click the External IP address for dev-instance.

    Instances tab with External IP 35.184.33.34 highlighted

    Note: Ensure that your browser connects using http:// (not https://), because the simple test server is listening on port 80 over unencrypted HTTP.

    A browser window opens and displays a Hello GCP dev! message from Python.

Test completed task

Click Check my progress to verify your performed task. If you have completed the task successfully, you will receive an assessment score.

Run application software to get a success response
  1. Return to the SSH terminal window, and stop the web server application by pressing CTRL+C.

  2. Install the Python packages needed to enumerate Compute Engine VM instances:

    sudo pip3 install -r requirements.txt --break-system-packages
  3. In the SSH terminal window, run the following command to run a simple Python application that lists Compute Engine instances:

    python3 list-gce-instances.py {{{project_0.project_id|PROJECT_ID}}} --zone={{{project_0.default_zone|ZONE}}}

    Your instance name should appear in the SSH terminal window.

    Example output:

    Instance in project {{{project_0.project_id|PROJECT_ID}}} and zone "{{{project_0.default_zone|ZONE}}}": - dev-instance

Test your understanding

Below are multiple-choice questions to reinforce your understanding of this lab's concepts. Answer them to the best of your abilities.

Congratulations!

You have completed the lab App Dev: Setting Up a Development Environment - Python. You successfully provisioned a Compute Engine virtual machine, configured the environment, and ran Python applications interacting with Google Cloud APIs!

Next steps / learn more

Learn more about Application Development in Google Cloud and Python on Google Cloud.

Manual Last Updated October 14, 2026

Lab Last Tested October 14, 2026

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

Avant de commencer

  1. Les ateliers créent un projet Google Cloud et des ressources pour une durée déterminée.
  2. Les ateliers doivent être effectués dans le délai imparti et ne peuvent pas être mis en pause. Si vous quittez l'atelier, vous devrez le recommencer depuis le début.
  3. En haut à gauche de l'écran, cliquez sur Démarrer l'atelier pour commencer.

Utilisez la navigation privée

  1. Copiez le nom d'utilisateur et le mot de passe fournis pour l'atelier
  2. Cliquez sur Ouvrir la console en navigation privée

Connectez-vous à la console

  1. Connectez-vous à l'aide des identifiants qui vous ont été attribués pour l'atelier. L'utilisation d'autres identifiants peut entraîner des erreurs ou des frais.
  2. Acceptez les conditions d'utilisation et ignorez la page concernant les ressources de récupération des données.
  3. Ne cliquez pas sur Terminer l'atelier, à moins que vous n'ayez terminé l'atelier ou que vous ne vouliez le recommencer, car cela effacera votre travail et supprimera le projet.

Ce contenu n'est pas disponible pour le moment

Nous pouvons vous prévenir par e-mail lorsqu'il sera disponible

Parfait !

Nous pouvons vous contacter par e-mail s'il devient disponible

Un atelier à la fois

Confirmez pour mettre fin à tous les ateliers existants et démarrer celui-ci

Utilisez la navigation privée pour effectuer l'atelier

Le meilleur moyen d'exécuter cet atelier consiste à utiliser une fenêtre de navigation privée. Vous éviterez ainsi les conflits entre votre compte personnel et le compte temporaire de participant, qui pourraient entraîner des frais supplémentaires facturés sur votre compte personnel.