Part-2: Deploy a Sample App in Google Cloud Platform (GCP)
Latchu@DevOps

Latchu@DevOps @latchudevops

About: Infra. Automation. Impact

Location:
Chennai, India
Joined:
Apr 10, 2025

Part-2: Deploy a Sample App in Google Cloud Platform (GCP)

Publish Date: Aug 15
6 0

Google Cloud Platform (GCP) makes it incredibly easy to spin up a Virtual Machine (VM) in just a few clicks.
In this post, I’ll guide you through creating a basic Compute Engine VM instance, perfect for beginners getting started with GCP.


1️⃣ Enable the Compute Engine API

Before you can create a VM, make sure the Compute Engine API is enabled for your project.
Go to:

Google Cloud Console → APIs & Services → Enable APIs → Search "Compute Engine API" → Enable
Enter fullscreen mode Exit fullscreen mode

2️⃣ Create a New VM Instance

Navigate to:

Google Cloud Console → Compute Engine → VM Instances → Create Instance
Enter fullscreen mode Exit fullscreen mode

3️⃣ Fill in the VM Details

Basic Info

  • Name: demo1-vm
  • Labels > environment: dev
  • Region: us-central1
  • Zone: us-central1-a

Basic-info


Machine Configuration

  • Series: E2
  • Machine Type: e2-micro (free-tier eligible)

machine-config


Operating system and storage

os-storage


Availability Policies

  • VM Provisioning Model: Standard
  • Display Device: ✅ Checked
  • Confidential VM Service: ❌ Unchecked (default)
  • Container: ❌ Unchecked (default)

Observability


Boot Disk

Leave defaults (Debian/Ubuntu image works fine for now)


Identity and API Access

  • Service Account: Compute Engine default
  • Access Scopes: Allow default access

Security


Firewall

✅ Allow HTTP Traffic (so you can host a simple web server later)

Networking


Advanced Options

Leave default for now (we’ll cover these in detail in future posts)


4️⃣ Create the VM

Click Create and wait for GCP to provision your instance.
In a few moments, you’ll have your VM ready to connect via SSH or use for your workloads.

Active-vm


5️⃣ Connect to the VM via SSH

Go to:

Google Cloud Console → Compute Engine → VM Instances → demo1-vm
Enter fullscreen mode Exit fullscreen mode

Click SSH → Open in browser window


🛠 What Happens in the Background?

When you open an SSH connection in the browser, Google Cloud:

  • Generates temporary SSH keys in the background
  • Transfers the public key to your VM
  • Appends the public key to:
~/.ssh/authorized_keys
Enter fullscreen mode Exit fullscreen mode
  • Starts the SSH session directly in your browser tab

You can verify the key by running inside the VM:

cat ~/.ssh/authorized_keys
Enter fullscreen mode Exit fullscreen mode

6️⃣ Create the Web Server Install Script

Let’s create a simple script that installs nginx and sets up a test page.

nano webserver-install.sh
Enter fullscreen mode Exit fullscreen mode

Add the below content into the webserver-install.sh

#!/bin/bash
sudo apt install -y telnet
sudo apt install -y nginx
sudo systemctl enable nginx
sudo chmod -R 755 /var/www/html
HOSTNAME=$(hostname)
sudo echo "<!DOCTYPE html> <html> <body style='background-color:rgb(250, 210, 210);'> <h1>Welcome to Latchu@DevOps - WebVM App1 </h1> <p><strong>VM Hostname:</strong> $HOSTNAME</p> <p><strong>VM IP Address:</strong> $(hostname -I)</p> <p><strong>Application Version:</strong> V1</p> <p>Google Cloud Platform - Demos</p> </body></html>" | sudo tee /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

Save and exit (CTRL+O, CTRL+X), then make it executable:

chmod +x webserver-install.sh
./webserver-install.sh
Enter fullscreen mode Exit fullscreen mode

ssh-browser


7️⃣ Access the Web Server

Find your VM’s External IP in the VM details page

Open your browser and visit:

http://<external-ip-of-vm>
Enter fullscreen mode Exit fullscreen mode

Access-the-app

Comments 0 total

    Add comment