← All Projects
GCP • Terraform • IaC

Auto-Scaling Web App with IaC

A highly available and scalable web application deployed on Google Cloud Platform, fully automated using Terraform Infrastructure as Code.

Role

Cloud Engineer

Stack

Terraform, Compute Engine, VPC

Deployment

Terraform

Outcome

Auto-Scaling • High Availability

The Challenge

Deploying virtual machines manually is prone to human error and difficult to scale. The goal of this project was to design a robust, self-healing cloud architecture that scales automatically based on traffic, and to automate its provisioning entirely through code.

The system needed to:

Architecture Overview

The solution leverages a modern multi-tier GCP networking topology, built strictly using Terraform declarative code.

GCP Architecture Diagram showing Terraform deploying a VPC with a Regional Load Balancer and an Auto-scaling Managed Instance Group.

Fig 1. GCP Architecture — Auto-Scaling Web Infrastructure

How It Works

Step 01 — Networking

Custom VPC & NAT

Terraform provisions a custom VPC with distinct subnets. A Cloud NAT gateway ensures private instances can securely download updates without public IP addresses.

Step 02 — Compute

Instance Templates

A Compute Engine Instance Template is defined to pull a startup script securely from Google Cloud Storage, installing Apache and serving the application automatically upon boot.

Step 03 — Scale

Managed Instance Group

An Auto-scaling MIG dynamically adds or removes Virtual Machines based on CPU utilization thresholds, ensuring high performance during traffic spikes.

Step 04 — Traffic

Load Balancing

A Regional External HTTP Load Balancer with a proxy-only subnet routes incoming user requests to the healthiest instances across multiple zones.

Implementation

The entire infrastructure is defined as code. A single command handles the provisioning of the VPC, subnets, routers, firewalls, instance templates, and load balancers.

Tech Stack

Compute Engine VPC / Cloud NAT Load Balancer Cloud Storage Terraform (IaC)
← All Projects