Launching Your First GCP Compute Engine Instance

Hello, cloud adventurers! 👋 Ready to take your first step into the Google Cloud Platform (GCP) universe? Today, we’ll guide you through launching your very first Compute Engine instance. Whether you prefer the GCP Console or the gcloud command-line tool, we’ve got you covered. We’ll also delve into SSH access, firewall settings, persistent disks, and machine types. So buckle up, and let’s get cloud computing! ☁️💻


Introduction to Compute Engine 🛠️

Compute Engine is GCP’s Infrastructure-as-a-Service (IaaS) offering that allows you to create and run virtual machines (VMs) on Google’s infrastructure. It’s like having your own data center, but without the hassle of managing physical hardware! 🎉

Compute Engine Overview | Google Cloud


Prerequisites ✅

Before we start, make sure you have:

  • A Google Cloud account with billing enabled. (Don’t worry, we’ll stay within the free tier!)
  • Google Cloud SDK installed if you plan to use the command-line method.

Installing Cloud SDK | Google Cloud


Launching an Instance via GCP Console 🖥️

Step 1: Navigate to Compute Engine 🗺️

  1. Log in to your GCP Console at <a href=”https://console.cloud.google.com” target=”_blank”>console.cloud.google.com</a>.
  2. In the Navigation Menu (three horizontal lines at the top-left), select Compute Engine > VM instances.

Quickstart Using a Linux VM | Compute Engine Docs


 

The Compute Engine VM Instances page showing a list of instances (currently empty).


Step 2: Configure Your Instance ⚙️

  1. Click on “Create Instance” at the top.
  2. Give your instance a name (e.g., my-first-vm).
  3. Choose a region and zone close to your users or services.

Regions and Zones | Compute Engine Docs

 

 

 


Step 3: Customize Machine Type 🖨️

  1. Under Machine configuration, click on “Machine family” and select “E2” (cost-effective for general purposes).
  2. Choose a machine type like e2-micro to stay within the free tier.

Machine Types | Compute Engine Docs

Selecting the E2 machine family and e2-micro type.

Step 4: Configure Boot Disk 💾

  1. In the Boot disk section, click “Change”.
  2. Choose an operating system. We’ll go with Ubuntu 20.04 LTS for its popularity and ease of use.
  3. Keep the default Standard persistent disk and 10 GB size.

Operating System Images | Compute Engine Docs


 

Selecting Debian Linux as the boot disk image.


Step 5: Set Up Firewall Rules 🔥

  1. Under Firewall, check “Allow HTTP traffic” and “Allow HTTPS traffic” if you plan to run web services.
  2. This will automatically create firewall rules to allow traffic on ports 80 and 443.

Firewall Rules Overview | VPC Docs


Step 6: Review and Create 👀

  1. Double-check your configurations.
  2. Click “Create”.
  3. Your VM instance will start provisioning. Grab a coffee—it takes just a moment! ☕️

 

 

The VM instance showing a “Running” status after creation.


Connecting via SSH 🔑

  1. In the VM instances list, find your instance.
  2. Click on “SSH” in the Connect column.
  3. A new window will open, connecting you to your VM.

Connecting to Instances | Compute Engine Docs


 

The SSH terminal window connected to your VM instance.


Launching an Instance via gcloud Command-Line 💻

Step 1: Install and Initialize Cloud SDK 🛠️

  1. Download and install the Google Cloud SDK from cloud.google.com/sdk/docs/install.

  2. Initialize the SDK: gcloud init

  3. Follow the prompts to log in and set your default project.

Initializing Cloud SDK | Google Cloud


Step 2: Create the Instance 📝

Run the following command to create an instance:

gcloud compute instances create my-cli-vm
–machine-type=e2-micro
–image-family=ubuntu-2004-lts
–image-project=ubuntu-os-cloud
–zone=us-central1-a
–tags=http-server,https-server

  • --machine-type: Specifies the machine type.
  • --image-family and --image-project: Define the OS image.
  • --zone: Specifies the zone.
  • --tags: Used for firewall rules.

Creating and Starting an Instance | Compute Engine Docs

Steps in the command-line instance creation process.

Understanding Persistent Disks 💾

Persistent disks are durable storage devices that function similarly to physical disks in a desktop or server. They can be:

  • Standard (HDD): Cost-effective magnetic disks.
  • SSD (Solid State Drive): Faster but more expensive.

You can detach a persistent disk from one instance and attach it to another, preserving your data.

Persistent Disks | Compute Engine Docs


 

The disks attached to your VM instance, showing size and type.


Managing Firewall Settings 🔥

Firewall rules control the traffic to and from your instances.

  • Default Deny: By default, all incoming traffic is blocked.

  • Creating Rules:

    1. Navigate to VPC Network > Firewall rules.
    2. Click “Create Firewall Rule”.
    3. Define the targets, source IP ranges, and protocols/ports.
  • Using Tags: Apply tags to instances and reference them in firewall rules.

Using Firewall Rules | VPC Docs

Steps to create a firewall rule.

Machine Types and Cost Considerations 💰

GCP offers various machine types tailored to different workloads:

  • General-Purpose: Balanced compute, memory, and storage.
  • Compute-Optimized: High-performance CPUs for compute-intensive tasks.
  • Memory-Optimized: For memory-intensive applications.

Machine Types | Compute Engine Docs

Cost Tips:

  • Use E2 Instances: Cost-effective for general use.
  • Sustained Use Discounts: Automatically applied discounts for running instances for long periods.
  • Preemptible VMs: Up to 80% cheaper but can be terminated at any time.

Preemptible VM Instances | Compute Engine Docs

Machine families resource and comparison guide

A comparison chart of different machine types and their specifications.


Cleanup: Deleting Your Instance 🧹

Don’t forget to delete your instance when you’re done to avoid unexpected charges.

  1. Go back to Compute Engine > VM instances.
  2. Select your instance.
  3. Click “Delete” at the top.
  4. Confirm the deletion.

Stopping or Deleting an Instance | Compute Engine Docs


 

Confirmation prompt for deleting the VM instance.


Conclusion 🎉

Congratulations! You’ve successfully launched your first GCP Compute Engine instance both via the GCP Console and the gcloud command-line tool. You’ve also learned about SSH access, firewall settings, persistent disks, and machine types.

Now you’re all set to explore the endless possibilities that GCP offers. Whether you’re deploying a web app, running computations, or just tinkering around, the cloud is your playground! 🌈


Pro Tip: Always monitor your resource usage to stay within budget. GCP’s Billing Alerts can help you keep track. 💡

Creating and Managing Budgets | Cloud Billing Docs


Happy Cloud Computing! ☁️🤓


Additional Resources 📚


Disclaimer: This guide is for educational purposes. Always refer to the official GCP documentation for the most up-to-date information.

Scroll to Top