Section 1: End-to-End Auto Scaling with ALB
Architecture
- ALB distributes traffic to EC2 instances in multiple AZs
- ASG launches and terminates instances automatically
- CloudWatch metrics control scaling events
Steps
Step 1: Create Launch Template
- AMI: Amazon Linux 2
- t2.micro
- SG: allow HTTP
- User Data (simple app):
#!/bin/bash
sudo yum update -y
sudo yum install -y httpd
echo "Hello from kaptaindevops ASG instance" > /var/www/html/index.html
sudo systemctl start httpd
sudo systemctl enable httpd
Step 2: Create Target Group (HTTP 80)
Step 3: Create Application Load Balancer
- Internet facing
- Add listener HTTP :80
- Attach target group
Step 4: Create ASG