How to Create Your First Virtual Machine (VM) in Google Cloud Platform (GCP)

Complete Step-by-Step Visual Guide: Enabling APIs, Compute Engine Setup, Firewall Security Rules & In-Browser SSH Access

⏱️ 12 Min Read 🏷️ GCP Compute Engine ⚡ Level: Beginner to Pro

Virtual Machines are the foundational building block of cloud computing. In Google Cloud Platform (GCP), virtual servers are managed under Compute Engine, an Infrastructure as a Service (IaaS) component that lets you run Linux and Windows workloads on Google's ultra-fast global infrastructure.

In this guide, you will learn the exact end-to-end visual workflow: from enabling required API services, configuring your first VM instance, securing it with VPC Firewall Rules (GCP's Security Groups), to connecting live via Browser SSH.

💡 What You Will Master

  • Enabling the Compute Engine API service in the API Library.
  • Navigating the Compute Engine dashboard and launching instances.
  • Setting Machine Family, Series E2, and Machine Types (e2-micro / e2-medium).
  • Changing Boot Disk to Ubuntu 22.04 LTS / Debian Linux.
  • Configuring VPC Firewall Rules for HTTP (Port 80), HTTPS (Port 443), and custom ports.
  • Connecting via 1-click in-browser SSH terminal and managing VM start/stop operations.

1. Prerequisites

  • An active Google Cloud Account (New accounts get $300 in free credits).
  • An active GCP Project (e.g., my-web-project or my-first-devops-project).
  • A modern web browser (Chrome, Edge, or Firefox).

2. Enabling Required API Services in GCP

In newly created Google Cloud projects, APIs are disabled by default. Before creating any virtual machines, you must enable the Compute Engine API (compute.googleapis.com).

1 Open APIs & Services > Library & Click "ENABLE"

  1. Log in to Google Cloud Console.
  2. Click the Navigation Menu (≡) in the top-left corner > APIs & Services > Library.
  3. Search for Compute Engine API and click on the result.
  4. Click the prominent blue ENABLE button highlighted below.
Google Cloud Console - Enable Compute Engine API

Figure 1: Google Cloud Console — Enabling the Compute Engine API in the API Library.

💻 Command-Line Alternative (Google Cloud Shell)

If you prefer using the command line, you can click the Cloud Shell icon in the top header and run:

# Enable Compute Engine API in your active GCP project
gcloud services enable compute.googleapis.com

3. Step-by-Step: Creating Your First VM Instance

1 Open Compute Engine & Configure Instance

Navigate to Compute Engine > VM instances, and click + CREATE INSTANCE. Configure the following parameters:

  • Name: devops-web-server-01
  • Region: us-central1 (Iowa) & Zone: us-central1-a
  • Series: E2 (Cost-optimized, versatile VMs)
  • Machine type: e2-micro (2 vCPU, 1 GB memory)Free Tier eligible
  • Boot disk: Debian GNU/Linux or Ubuntu 22.04 LTS (10 GB Balanced persistent disk)
  • Firewall: Check ☑️ Allow HTTP traffic and ☑️ Allow HTTPS traffic
Google Cloud Console - Create an Instance Settings

Figure 2: Complete Compute Engine Instance Configuration: Name, Region, Series E2, Machine Type e2-micro, and Firewall.

4. Configuring VPC Firewall Rules (GCP Security Groups)

In Google Cloud, network security is managed via VPC Firewall Rules and Target Tags. To allow incoming traffic to your web apps or custom applications (e.g. port 80, 443, 8080, or 3000):

  1. Go to VPC network > Firewall in the GCP Console.
  2. Click + CREATE FIREWALL RULE at the top bar.
  3. Set Name: allow-web-traffic
  4. Set Targets: All instances in the network
  5. Set Source filter: IPv4 ranges > 0.0.0.0/0
  6. Under Protocols and ports, check tcp and specify ports: 80, 443, 8080
  7. Click CREATE.
Google Cloud Console - Create a VPC Firewall Rule

Figure 3: VPC Network — Creating a Firewall Rule allowing Ingress TCP traffic on ports 80, 443, and 8080 from anywhere (0.0.0.0/0).

Rule Name Direction Protocol / Port Source IP Range Purpose
default-allow-ssh Ingress TCP: 22 0.0.0.0/0 SSH Remote Terminal Access
allow-web-traffic Ingress TCP: 80, 443, 8080 0.0.0.0/0 Public Web & Container Traffic
allow-custom-dev Ingress TCP: 3000, 5000 Your_IP/32 Development & CI/CD Testing

5. Launching the VM & Connecting via SSH

1 View Running VM & Click "SSH"

After clicking Create at the bottom of the page, Google Cloud provisions the virtual machine in 15–30 seconds. On the VM instances dashboard, your instance will show a green checkmark status ✔ Running with its assigned Internal IP and External IP.

Under the Connect column, simply click the blue SSH button.

Google Cloud Console - VM Instances Dashboard with Running Status and SSH Button

Figure 4: Compute Engine Dashboard displaying active VM 'devops-web-server-01', External IP, and the Connect SSH button.

6. In-Browser SSH Terminal & Web Server Deployment

Clicking SSH opens a secure, in-browser terminal session connected straight to your Linux virtual machine. Deploy an Nginx web server by running the following commands:

# 1. Update package lists
sudo apt update

# 2. Install Nginx web server
sudo apt install nginx -y

# 3. Verify Nginx service status
systemctl status nginx
Google Cloud in-browser SSH Terminal Session with Nginx active

Figure 5: In-Browser SSH Web Terminal — Installing Nginx and verifying active (running) service status.

Open a new browser tab and navigate to http://<YOUR_EXTERNAL_IP> (e.g. http://34.68.102.45) to view your live Nginx web server running directly on Google Cloud!

7. Managing VM Lifecycle (Start, Stop & Delete)

⚠️ Best Practices for Cost Management

To avoid consuming your free credits when not actively using the virtual machine:

  • STOP: Halts CPU/RAM billing while keeping your disk and files intact. Select the VM > click STOP in the top toolbar or 3-dots menu .
  • DELETE: Permanently deletes the VM and attached disk when your lab experiment is complete.
  • Set Budget Alerts: Navigate to Billing > Budgets & alerts to set a $1 or $5 threshold.

🎉 Summary Checklist

Congratulations! You have mastered:

  1. Enabling the Compute Engine API in Google Cloud.
  2. Configuring VM parameters (Name, Region, E2 series, e2-micro).
  3. Creating custom VPC Firewall rules for web and application ports.
  4. Connecting via 1-click in-browser SSH and deploying live web services.