Code from github to self hosted with git tea in AWS
189
aws-scalable-webapp-alb/AWS-SCALABLE-WEBAPP-ALB-README.md
Normal file
@@ -0,0 +1,189 @@
|
||||
# 🚀 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 served through the Application Load Balancer DNS — no direct EC2 IP
|
||||
|
||||
### Target Group — Both Instances Healthy in different AZ's
|
||||

|
||||
> Both EC2 instances passing health checks across two Availability Zones
|
||||
|
||||
### Auto Scaling Group — Instance Management after deleting
|
||||

|
||||
> 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
|
||||

|
||||
|
||||

|
||||
>Confirmed notification subscription
|
||||
|
||||
### CloudWatch Monitoring Dashboard
|
||||

|
||||
> 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.
|
||||
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-01.png
Normal file
|
After Width: | Height: | Size: 633 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-02.png
Normal file
|
After Width: | Height: | Size: 435 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-03.png
Normal file
|
After Width: | Height: | Size: 436 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-04.png
Normal file
|
After Width: | Height: | Size: 614 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-05.png
Normal file
|
After Width: | Height: | Size: 467 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-06.png
Normal file
|
After Width: | Height: | Size: 512 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-07.png
Normal file
|
After Width: | Height: | Size: 427 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-08.png
Normal file
|
After Width: | Height: | Size: 483 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-09.png
Normal file
|
After Width: | Height: | Size: 311 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-10.png
Normal file
|
After Width: | Height: | Size: 505 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-11.png
Normal file
|
After Width: | Height: | Size: 421 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-12.png
Normal file
|
After Width: | Height: | Size: 515 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-13.png
Normal file
|
After Width: | Height: | Size: 356 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-14.png
Normal file
|
After Width: | Height: | Size: 588 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-15.png
Normal file
|
After Width: | Height: | Size: 420 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-16.png
Normal file
|
After Width: | Height: | Size: 465 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-17.png
Normal file
|
After Width: | Height: | Size: 383 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-18.png
Normal file
|
After Width: | Height: | Size: 379 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-19.png
Normal file
|
After Width: | Height: | Size: 450 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-20.png
Normal file
|
After Width: | Height: | Size: 534 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-21.png
Normal file
|
After Width: | Height: | Size: 414 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-22.png
Normal file
|
After Width: | Height: | Size: 347 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-23.png
Normal file
|
After Width: | Height: | Size: 448 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-24.png
Normal file
|
After Width: | Height: | Size: 489 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-25.png
Normal file
|
After Width: | Height: | Size: 538 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-26.png
Normal file
|
After Width: | Height: | Size: 526 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-27.png
Normal file
|
After Width: | Height: | Size: 522 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-28.png
Normal file
|
After Width: | Height: | Size: 478 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-29.png
Normal file
|
After Width: | Height: | Size: 467 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-30.png
Normal file
|
After Width: | Height: | Size: 510 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-31.png
Normal file
|
After Width: | Height: | Size: 604 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-32.png
Normal file
|
After Width: | Height: | Size: 660 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-33.png
Normal file
|
After Width: | Height: | Size: 410 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-34.png
Normal file
|
After Width: | Height: | Size: 481 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-35.png
Normal file
|
After Width: | Height: | Size: 692 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-36.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-37.png
Normal file
|
After Width: | Height: | Size: 482 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-38.png
Normal file
|
After Width: | Height: | Size: 484 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-39.png
Normal file
|
After Width: | Height: | Size: 501 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-40.png
Normal file
|
After Width: | Height: | Size: 434 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-41.png
Normal file
|
After Width: | Height: | Size: 352 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-42.png
Normal file
|
After Width: | Height: | Size: 516 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-43.png
Normal file
|
After Width: | Height: | Size: 511 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-44.png
Normal file
|
After Width: | Height: | Size: 422 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-45.png
Normal file
|
After Width: | Height: | Size: 440 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-46.png
Normal file
|
After Width: | Height: | Size: 424 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-47.png
Normal file
|
After Width: | Height: | Size: 595 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-48.png
Normal file
|
After Width: | Height: | Size: 655 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-49.png
Normal file
|
After Width: | Height: | Size: 455 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-50.png
Normal file
|
After Width: | Height: | Size: 696 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-51.png
Normal file
|
After Width: | Height: | Size: 513 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-52.png
Normal file
|
After Width: | Height: | Size: 546 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-53.png
Normal file
|
After Width: | Height: | Size: 470 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-54.png
Normal file
|
After Width: | Height: | Size: 608 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-55.png
Normal file
|
After Width: | Height: | Size: 446 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-56.png
Normal file
|
After Width: | Height: | Size: 557 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-57.png
Normal file
|
After Width: | Height: | Size: 546 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-58.png
Normal file
|
After Width: | Height: | Size: 521 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-59.png
Normal file
|
After Width: | Height: | Size: 546 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-60.png
Normal file
|
After Width: | Height: | Size: 561 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-61.png
Normal file
|
After Width: | Height: | Size: 568 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-62.png
Normal file
|
After Width: | Height: | Size: 597 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-63.png
Normal file
|
After Width: | Height: | Size: 368 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-64.png
Normal file
|
After Width: | Height: | Size: 590 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-65.png
Normal file
|
After Width: | Height: | Size: 776 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-66.png
Normal file
|
After Width: | Height: | Size: 793 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-67.png
Normal file
|
After Width: | Height: | Size: 838 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-68.png
Normal file
|
After Width: | Height: | Size: 342 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-69.png
Normal file
|
After Width: | Height: | Size: 390 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-70.png
Normal file
|
After Width: | Height: | Size: 449 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-71.png
Normal file
|
After Width: | Height: | Size: 421 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-72.png
Normal file
|
After Width: | Height: | Size: 492 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-73.png
Normal file
|
After Width: | Height: | Size: 480 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-74.png
Normal file
|
After Width: | Height: | Size: 641 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-75.png
Normal file
|
After Width: | Height: | Size: 432 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-76.png
Normal file
|
After Width: | Height: | Size: 490 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-77.png
Normal file
|
After Width: | Height: | Size: 570 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-78.png
Normal file
|
After Width: | Height: | Size: 316 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-79.png
Normal file
|
After Width: | Height: | Size: 786 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-80.png
Normal file
|
After Width: | Height: | Size: 567 KiB |
BIN
aws-scalable-webapp-alb/images/aws-scalable-webapp-alb-81.png
Normal file
|
After Width: | Height: | Size: 415 KiB |