Skip to content
Learni
View all tutorials
Cloud Computing

How to Deploy a Compute Engine Instance in 2026

Lire en français

Introduction

Google Compute Engine lets you create customizable virtual machines in the cloud. This tutorial walks you through deploying your first instance step by step. You will learn to use the gcloud CLI for precise, reproducible control. This approach suits developers and system administrators who want to automate their deployments.

Prerequisites

  • Google Cloud account with billing enabled
  • Basic command-line knowledge
  • Google Cloud SDK installed on your machine

Installing the Google Cloud SDK

terminal
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
gcloud init

This command downloads and installs the Google Cloud SDK. The gcloud init command launches the initial configuration wizard to connect your account.

Authentication and Project Setup

terminal
gcloud auth login
gcloud config set project MON-PROJET-ID

Authenticate with Google Cloud and set the active project. Replace MON-PROJET-ID with your actual project ID.

Creating the VM Instance

terminal
gcloud compute instances create mon-premiere-vm \
  --zone=europe-west1-b \
  --machine-type=e2-micro \
  --image-family=debian-11 \
  --image-project=debian-cloud \
  --tags=http-server

This command creates an e2-micro instance running Debian 11 in the europe-west1-b zone. The http-server tag opens port 80 through the firewall.

SSH Connection to the Instance

terminal
gcloud compute ssh mon-premiere-vm --zone=europe-west1-b

This command establishes a secure SSH connection to your instance without manual key management.

Firewall Configuration

terminal
gcloud compute firewall-rules create allow-http \
  --allow tcp:80 \
  --target-tags=http-server \
  --direction=INGRESS

This rule allows incoming HTTP traffic on port 80 for all instances tagged with http-server.

Best Practices

  • Always choose the zone closest to your users
  • Use machine types suited to your workload
  • Enable automatic security updates
  • Name resources clearly with consistent conventions

Common Errors

  • Forgetting to specify the zone in each command
  • Using an overly expensive machine type for testing
  • Neglecting firewall rule configuration
  • Not enabling the Compute Engine API before use

Going Further

Discover our complete Google Cloud courses to deepen your knowledge of automation and production best practices.

How to Deploy a Compute Engine Instance in 2026 | Learni