π Introduction
In this hands-on project, I built a production-ready AWS architecture using core services like VPC, Application Load Balancer, Auto Scaling Group, EC2, and NAT Gateway.
This setup follows AWS best practices:
Secure networking
High availability
Automatic scaling
Zero public access to EC2 instances
This guide is beginner-friendly, yet interview-ready.
π§ What You Will Learn
β
How to design a secure AWS VPC
β
Public vs Private Subnets (real use-case)
β
Application Load Balancer (ALB)
β
Auto Scaling Group (ASG)
β
NAT Gateway for outbound internet
β
Real-world architecture used in companies
ποΈ Architecture Overview
Internet
|
βΌ
Application Load Balancer (Public Subnets)
|
βΌ
Target Group
|
βΌ
Auto Scaling Group
(EC2 Instances in Private Subnets)
|
βΌ
NAT Gateway β Internet (Outbound Only)
π EC2 instances have NO public IPs
π Only ALB is exposed to the internet
π οΈ Services Used
Amazon VPC
EC2 (Ubuntu)
Application Load Balancer
Auto Scaling Group
Target Groups
NAT Gateway
Elastic IP
Security Groups
π¦ Step-by-Step Implementation
1οΈβ£ Create a Custom VPC
CIDR: 10.0.0.0/16
Enable:
DNS Hostnames
DNS Resolution
2οΈβ£ Create Subnets
Create 4 subnets:
Public Subnets
Public-Subnet-1 (ALB)
Public-Subnet-2 (NAT Gateway)
Private Subnets
Private-Subnet-1 (EC2)
Private-Subnet-2 (EC2)
β οΈ Enable Auto-assign Public IP = YES only for public subnets
3οΈβ£ Internet Gateway
Create and attach an Internet Gateway to the VPC
Required for ALB and NAT Gateway
4οΈβ£ NAT Gateway (CRITICAL)
Create NAT Gateway in public subnet
Attach Elastic IP
Allows private EC2 to access internet securely
5οΈβ£ Route Tables
Public Route Table
0.0.0.0/0 β Internet Gateway
Private Route Table
0.0.0.0/0 β NAT Gateway
Associate correctly with subnets.
6οΈβ£ Security Groups
πΉ ALB Security Group
HTTP (80) β 0.0.0.0/0
πΉ EC2 Security Group
HTTP (80) β ALB Security Group
SSH (22) β Your IP (optional)
π EC2 is accessible only via ALB
7οΈβ£ Launch Template (EC2)
AMI: Ubuntu 22.04
Instance Type: t2.micro
π§Ύ User Data Script
!/bin/bash
apt update -y
apt install apache2 -y
systemctl start apache2
systemctl enable apache2
echo "
Welcome from ALB + Auto Scaling
Hostname: $(hostname)
" > /var/www/html/index.html8οΈβ£ Target Group
Target Type: Instance
Protocol: HTTP
Port: 80
Health Check Path: /
9οΈβ£ Application Load Balancer
Type: Internet-facing
Subnets: Public Subnets
Listener: HTTP 80
Forward to Target Group
π Auto Scaling Group
Use Launch Template
Subnets: Private Subnets
Desired: 2
Min: 1
Max: 3
Attach to ALB Target Group
π Optional: CPU-based scaling policy
β Final Verification
Copy ALB DNS name
Paste into browser
Refresh multiple times
π You will see different hostnames
This confirms:
Load balancing
Auto scaling
High availability
π GitHub Repository
π Project Source Code & Documentation
π https://github.com/IrfanPasha05/aws-alb-autoscaling-project
Includes:
Folder structure
User-data scripts
Setup steps
Troubleshooting guide
π― Why This Project Matters
This architecture is used in:
Real production environments
Enterprise applications
DevOps & Cloud Engineer roles
Perfect for:
Resume
Interviews
Portfolio
LinkedIn & DEV
π§© Future Enhancements
HTTPS with ACM
Custom domain (Route 53)
CloudFront CDN
Monitoring with CloudWatch
π Final Thoughts
This project strengthened my understanding of AWS networking, security, and scalability. If youβre learning AWS or preparing for cloud roles β build this once, and youβll remember it forever.
Happy Clouding βοΈπ
Top comments (0)