Edit on GitHub
Report issue
Page history

Compute Engine quickstart - Create a virtual machine

Author(s): @jscud ,   Published: 2019-07-31

Compute Engine quickstart: Create a virtual machine

Take the interactive version of this tutorial, which runs in the Google Cloud Platform (GCP) Console:

Open in GCP Console

This tutorial explains how to create a virtual machine instance in Compute Engine using the GCP Console.

Project setup

GCP organizes resources into projects. This allows you to collect all of the related resources for a single application in one place.

Begin by creating a new project or selecting an existing project for this tutorial.

For details, see Creating a project.

Open the Navigation menu in the upper-left corner of the console, and then select Compute Engine.

Create a virtual machine instance

  1. In the VM instances section, click Create.

  2. Enter a name for this instance.

  3. Choose a region and a zone for this instance.

  4. In the Machine type menu, select micro, which specifies a lower-cost machine type. (Learn more about pricing.)

  5. In the Firewall selector section, select Allow HTTP traffic. This opens port 80 (HTTP) to access the app.

  6. Click Create to create the instance.

The instances need to finish being created before the tutorial can proceed. To track the progress of this activity and others, click the Notifications button in the navigation bar in the upper-right corner of the console.

VM instances page

While the instance is being created, take your time to explore the VM instances page.

At the top is a control panel with controls for doing the following:

  • Create a VM instance or instance group.
  • Start, stop, reset, and delete instances.

The body of the page contains a list of your VMs.

Set up a web server on the VM instance

After the VM instance is created, you run a web server on the virtual machine.

For this tutorial, you connect using Cloud Shell, which is a built-in command-line tool for the console.

Open the Cloud Shell

Open Cloud Shell by clicking the Activate Cloud Shell button in the navigation bar in the upper-right corner of the console.

Connect to the instance

Connect to the VM using SSH:

gcloud compute --project "" ssh --zone [vm-zone] [vm-name]

Replace [vm-zone] and [vm-name] with the zone and name of the instance that you created.

If this is your first time using SSH from Cloud Shell, follow the instructions to create a private key.

It may take several minutes for the SSH key to propagate.

Run a simple web server

Create a simple index.html file:

echo "Hello, world!" > index.html

Start a simple Python webserver:

sudo python -m SimpleHTTPServer 80

Visit the webserver application

Visit your webserver over an HTTP connection at the external IP address listed next to the instance in the VM instances table. Use a URL in the form http://[external-ip-address].


To remove your instance, select the checkbox next to the instance name and click the Delete button.


You're done!

Here are some suggestions for what you can do next:

Submit a Tutorial

Share step-by-step guides


Request a Tutorial

Ask for community help


GCP Tutorials

Tutorials published by GCP


Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Site Policies. Java is a registered trademark of Oracle and/or its affiliates.