# ๐Ÿš€ AWS Scalable Web Application โ€” ALB + ASG A production-grade, self-healing web application deployed on AWS using an Application Load Balancer, Auto Scaling Group, and EC2 across multiple Availability Zones. Mimics how platforms like **Heroku / Railway** manage scalable deployments automatically. --- ## ๐Ÿ“ธ Screenshots > All build screenshots are available in the [`/images`](./images) folder, numbered `1` through `81` in chronological build order. **Key screenshots inline:** ### App Running via ALB DNS ![App running via ALB](./images/aws-scalable-webapp-alb-63.png) > App served through the Application Load Balancer DNS โ€” no direct EC2 IP ### Target Group โ€” Both Instances Healthy in different AZ's ![Target group healthy](./images/aws-scalable-webapp-alb-43.png) > Both EC2 instances passing health checks across two Availability Zones ### Auto Scaling Group โ€” Instance Management after deleting ![ASG instances](./images/aws-scalable-webapp-alb-65.png) > ASG maintaining desired capacity across `ap-south-1a` and `ap-south-1b` after terminating an ec2 machine to check for auto healing ### AWS Notification -Subscription email ![Email subscription confirmation for cloudwatch notification](./images/aws-scalable-webapp-alb-78.png) ![CONFIRMED](./images/aws-scalable-webapp-alb-79.png) >Confirmed notification subscription ### CloudWatch Monitoring Dashboard ![CloudWatch dashboard](./images/aws-scalable-webapp-alb-81.png) > Real-time metrics โ€” CPU, request count, response time, instance count ---- ## ๐Ÿ—๏ธ Architecture ``` Internet โ”‚ โ–ผ Internet Gateway (scalable-webapp-igw) โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ VPC: scalable-webapp-vpc (10.0.0.0/16) โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ”‚ public-subnet-1a โ”‚ โ”‚ public-subnet-1b โ”‚ โ”‚ โ”‚ โ”‚ 10.0.1.0/24 โ”‚ โ”‚ 10.0.2.0/24 โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ–ผ โ–ผ โ”‚ โ”‚ Application Load Balancer (webapp-alb) โ”‚ โ”‚ โ”‚ HTTP :80 Listener โ”‚ โ”‚ โ–ผ โ”‚ โ”‚ Target Group (webapp-target-group) โ”‚ โ”‚ โ”œโ”€โ”€โ–ถ EC2 t3.micro โ€” ap-south-1a โœ“ healthy โ”‚ โ”‚ โ””โ”€โ”€โ–ถ EC2 t3.micro โ€” ap-south-1b โœ“ healthy โ”‚ โ”‚ โ–ฒ โ”‚ โ”‚ Auto Scaling Group (webapp-asg) โ”‚ โ”‚ min: 1 โ”‚ desired: 2 โ”‚ max: 4 โ”‚ โ”‚ CPU > 50% โ†’ scale out โ”‚ โ”‚ CPU < 30% โ†’ scale in โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ Launch Template (webapp-launch-template) โ”‚ โ”‚ Amazon Linux 2023 + nginx โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- ## โš™๏ธ AWS Services Used | Service | Purpose | |---|---| | **VPC** | Isolated network with public subnets across 2 AZs | | **EC2** | Compute โ€” runs nginx web server | | **Application Load Balancer** | Distributes traffic, health checks, single DNS entry | | **Auto Scaling Group** | Automatically adds/removes instances based on CPU | | **Launch Template** | Blueprint for identical EC2 instances | | **IAM Role** | EC2 permissions for S3 and CloudWatch | | **CloudWatch** | Metrics dashboard + CPU alarm via SNS email | | **Security Groups** | Layered firewall โ€” ALB faces internet, EC2 accepts ALB only | --- ## ๐Ÿ” Security Design ``` Internet โ†’ alb-sg (HTTP 0.0.0.0/0) โ†“ ec2-sg (HTTP from alb-sg ONLY) ``` EC2 instances are **not directly reachable** from the internet. All public traffic flows through the ALB only. This is a standard production security pattern. --- ## ๐Ÿ“ฆ Infrastructure Summary ### VPC & Networking | Resource | Value | |---|---| | VPC CIDR | `10.0.0.0/16` | | Public Subnet 1 | `10.0.1.0/24` โ€” ap-south-1a | | Public Subnet 2 | `10.0.2.0/24` โ€” ap-south-1b | | Internet Gateway | Attached to VPC | | Route Table | `0.0.0.0/0 โ†’ IGW` | ### Compute | Resource | Value | |---|---| | AMI | Amazon Linux 2023 | | Instance Type | t3.micro | | Web Server | nginx | | Deployment | User data script on launch | ### Auto Scaling | Setting | Value | |---|---| | Minimum | 1 | | Desired | 2 | | Maximum | 4 | | Scale-out trigger | CPU > 50% | | Scale-in trigger | CPU < 30% | ### Monitoring | Resource | Value | |---|---| | Dashboard | `webapp-monitoring` | | Alarm | `webapp-high-cpu` โ€” triggers at 70% | | Notification | SNS email alert | --- ## ๐Ÿ› ๏ธ Build Phases | Phase | What was built | |---|---| | 1 โ€” Networking | VPC, subnets, IGW, route table, security groups | | 2 โ€” Compute | Launch template, IAM role, test EC2, nginx + web app | | 3 โ€” Auto Scaling | ASG with target tracking scaling policy | | 4 โ€” Load Balancer | ALB, target group, listener, ASG integration | | 5 โ€” Monitoring | CloudWatch dashboard, CPU alarm, SNS notification | --- ## ๐Ÿ’ก Key Cloud Concepts Demonstrated - **High Availability** โ€” workload spread across 2 Availability Zones - **Horizontal Scaling** โ€” ASG adds instances under load, removes them when idle - **Self-healing Infrastructure** โ€” failed instances are automatically replaced by ASG - **Security Layering** โ€” EC2 not exposed directly, traffic flows ALB โ†’ EC2 only - **Infrastructure as a Blueprint** โ€” Launch Templates ensure every instance is identical - **Observability** โ€” CloudWatch dashboard + proactive alerting via SNS --- ## ๐Ÿงน Cleanup To avoid AWS charges after testing: 1. Delete **Auto Scaling Group** (this terminates all EC2 instances) 2. Delete **Application Load Balancer** 3. Delete **Target Group** 4. Delete **Launch Template** 5. Delete **CloudWatch Alarms and Dashboard** 6. Delete **VPC** (also removes subnets, IGW, route tables, security groups) 7. Delete **IAM Role** `ec2-webapp-role` 8. Delete **SNS Topic** `webapp-cpu-alert` --- ## ๐Ÿ“ Repository Structure ``` aws-scalable-webapp-alb/ โ”œโ”€โ”€ index.html # Web app deployed on EC2 via nginx โ”œโ”€โ”€ README.md # This file โ””โ”€โ”€ images/ # All build screenshots (1โ€“70, in chronological order) ``` --- ## Learning Journey Built as part of a hands-on AWS Cloud & DevOps learning journey.