
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a Compute Engine instance and add Nginx Server to your instance with necessary firewall rules.
/ 50
Create a new instance with gcloud.
/ 50
Compute Engine allows you to create virtual machines (VMs) that run different operating systems, including multiple flavors of Linux (Debian, Ubuntu, Suse, Red Hat, CoreOS) and Windows Server, on Google infrastructure. You can run thousands of virtual CPUs on a system that is designed to be fast and to offer strong consistency of performance.
In this hands-on lab, you create VM instances of various machine types using the Google Cloud console and the gcloud
command line in Cloud Shell. You also learn how to connect an NGINX web server to your VM.
Although you can easily copy and paste commands from the lab to the appropriate place, it is recommended that you type the commands yourself to reinforce your understanding of the core concepts.
In this lab, you learn how to perform the following tasks:
gcloud
command line.vim
, emacs
, or nano
.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:
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 left is the Lab Details pane with the following:
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.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Certain Compute Engine resources live in regions or zones. A region is a specific geographical location where you can run your resources. Each region has one or more zones. For example, the us-central1 region denotes a region in the Central United States that has zones us-central1-a
, us-central1-b
, us-central1-c
, and us-central1-f
.
Regions | Zones |
---|---|
Western US | us-west1-a, us-west1-b |
Central US | us-central1-a, us-central1-b, us-central1-d, us-central1-f |
Eastern US | us-east1-b, us-east1-c, us-east1-d |
Western Europe | europe-west1-b, europe-west1-c, europe-west1-d |
Eastern Asia | asia-east1-a, asia-east1-b, asia-east1-c |
Resources that live in a zone are referred to as zonal resources. Virtual machine Instances and persistent disks live in a zone. To attach a persistent disk to a virtual machine instance, both resources must be in the same zone. Similarly, if you want to assign a static IP address to an instance, the instance must be in the same region as the static IP.
Learn more from the Regions and zones documentation.
gcloud
on your own machine, the config settings are persisted across sessions. But in Cloud Shell, you need to set this for every new session or reconnection.
In this section, you create new predefined machine types with Compute Engine from the Cloud console.
In the Cloud console, on the Navigation menu (☰), click Compute Engine > VM Instances.
This may take a minute to initialize for the first time.
To create a new instance, click Create Instance.
In the Machine configuration:
Enter the values for the following fields:
Field | Value | Additional Information |
---|---|---|
Name | gcelab | Name for the VM instance |
Region | For more information about regions, see the Compute Engine guide, Regions and Zones. | |
Zone | Note: Remember the zone that you selected to use later. For more information about zones, see the Compute Engine guide, Regions and Zones. | |
Series | E2 |
|
Machine Type | e2-medium |
This is an e2-medium, 2-CPU, 4GB RAM instance. Several machine types are available, ranging from micro instance types to 32-core/208GB RAM instance types. For more information, see the Compute Engine guide, About machine families. |
Click OS and storage.
Click Change to begin configuring your boot disk and select the values for:
Several images are available, including Debian, Ubuntu, CoreOS, and premium images such as Red Hat Enterprise Linux and Windows Server. For more information, see the Operating System documentation.
Click Networking.
Select this option in order to access a web server that you install later.
Once all sections are configured, scroll down and click Create to launch your new virtual machine instance.
It should take about a minute for the VM, gcelab
, to be created. After gcelab
is created, the VM Instances page lists it in the VM instances list.
To use SSH to connect to the VM, click SSH to the right of the instance name, gcelab
.
This launches an SSH client directly from your browser.
Now you install an NGINX web server, one of the most popular web servers in the world, to connect your VM to something.
Run the following command to update the OS:
Expected output:
Run the following command to install NGINX:
Expected output:
Run the following command to confirm that NGINX is running:
Expected output:
To see the web page, return to the Cloud console and click the External IP link in the row for your machine, or add the External IP value to http://EXTERNAL_IP/
in a new browser window or tab.
A default web page should open that says: Welcome to nginx!
To check your progress in this lab, click Check my progress below. A checkmark means you're successful.
Instead of using the Cloud console to create a VM instance, use the command line tool gcloud
, which is pre-installed in Google Cloud Shell. Cloud Shell is an interactive shell environment for Google Cloud loaded with all the development tools you need (gcloud
, git
, and others) and offers a persistent 5-GB home directory.
In Cloud Shell, run the following gcloud
command to create a new VM instance from the command line:
Expected output:
To check your progress in this lab, click Check my progress below. A checkmark means you're successful.
The new instance has these default values:
e2-medium
machine type.When working in your own project, you can specify a custom machine type.
To see all the defaults, run the following command:
gcloud
uses if you are always working within one region/zone and you don't want to append the --zone
flag every time.
To do this, run these commands:
gcloud config set compute/zone ...
gcloud config set compute/region ...
To exit help
, press CTRL+C.
In the Cloud console, on the Navigation menu (), click Compute Engine > VM instances. Or if you still had the VM instances page open, just click Refresh.
Your two new instances should be listed.
You can also use SSH to connect to your instance via gcloud
. Make sure to add your zone, or omit the --zone
flag if you've set the option globally:
Enter Y to continue.
Press Enter through the passphrase section to leave the passphrase empty.
After connecting, disconnect from SSH by exiting from the remote shell with the command that follows:
Test your knowledge about Google Cloud by taking the quiz. (Please select multiple correct options if necessary.)
Compute Engine is the foundation of Google Cloud's infrastructure as a service. You created a VM with Compute Engine and can now map your existing server infrastructure, load balancers, and network topology to Google Cloud.
Continue your course with Get Started with Cloud Shell and gcloud, or check out the following lab:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated December 12, 2024
Lab Last Tested November 13, 2024
Copyright 2025 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.
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