Powered By GitBook
Compute Engine quickstart: Create a virtual machine
Create a virtual machine instance in Compute Engine.
Take the interactive version of this tutorial, which runs in the Cloud Console:
This tutorial explains how to create a virtual machine instance in Compute Engine using the Cloud Console.

Project setup

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

Navigate to Compute Engine

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

Create a virtual machine instance

    In the VM instances section, click Create.
    Enter a name for this instance.
    Choose a region and a zone for this instance.
    In the Machine type menu, select micro, which specifies a lower-cost machine type. (Learn more about pricing.)
    In the Firewall selector section, select Allow HTTP traffic. This opens port 80 (HTTP) to access the app.
    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.
Note: After the instance is created, your billing account will start being charged according to the Compute Engine pricing. You will remove the instance later to avoid extra charges.

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 </walkthrough-cloud-shell-icon>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 "{{project_id}}" 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:
Last modified 7mo ago