This repository documents the deployment of a 3-tier architecture on AWS, consisting of:
- Web Tier (Nginx + Node.js)
- Application Tier (Node.js + Internal Load Balancer)
- Database Tier (Amazon RDS MySQL)
The setup ensures scalability, security, and high availability using VPC, Security Groups, Load Balancers, Auto Scaling Groups, and Route53.
aws-blue-green-deployment/
|
├── 3tier-app-deployment-aws-main/
│ ├── application-code
│ ├── apptier/
│ ├── webtier/
├── install.sh
├── screenshots/
│ ├── Images
├── README.md
└── architecture.png
- VPC: Custom VPC (CIDR: 192.168.0.0/16) with 2 public and 4 private subnets.
- Security Groups: Separate SGs for Web ALB, Web Server, App ALB, App Server, and Database.
- Storage: S3 private bucket for application code and configuration files.
- IAM: Role for EC2 with SSM permissions.
- Database: RDS MySQL instance with private subnet group.
- App Tier: Node.js application servers behind an internal ALB.
- Web Tier: Nginx servers behind an external ALB with HTTPS via ACM.
- Scaling: Auto Scaling Groups for both Web and App tiers.
- DNS: Route53 for domain mapping.
- Create VPC:
192.168.0.0/16 - Subnets: 2 public, 4 private
- NAT Gateway in one AZ
- Security Groups:
- Web ALB SG → allow HTTP/HTTPS from
0.0.0.0/0 - Web SG → allow traffic from Web ALB SG
- App ALB SG → allow traffic from Web SG
- App SG → allow TCP 4000 from App ALB SG
- DB SG → allow MySQL (3306) from App SG
- Web ALB SG → allow HTTP/HTTPS from
- Create S3 bucket:
3-tier-project-demo - Upload application code and
install.sh - Update configs:
DbConfig.js→ RDS credentialsnginx.conf→ Internal ALB DNS
- Create role:
3-tier-role - Trusted entity: EC2
- Permissions:
AmazonEC2RoleforSSM
- Create DB Subnet Group (
tier-Subnet-Group) - Launch RDS MySQL instance (
my3tierdb) - Update App Tier config with DB endpoint and credentials
- Launch EC2 (Amazon Linux 2/2023, t2.micro) in private subnet
- Attach IAM role
- Connect via SSM
- Install Node.js, PM2, MySQL client
- Deploy app from S3
- Configure internal ALB + target group (port 4000, health check
/health)
- Launch EC2 (Amazon Linux 2/2023, t2.micro) in public subnet
- Install Node.js, Nginx
- Deploy web code from S3
- Replace default
nginx.confwith custom config - Configure external ALB + target group (port 80, health check
/)
- Create ACM certificate
- Attach certificate to external ALB listener
- Configure Route53 domain:
https://3tier-webapp.com
- Create AMIs for App and Web servers
- Define Launch Templates
- Create ASGs with min/max/desired capacity
- Attach respective ALBs
Once deployed:
- Access the application via the Route53 domain.
- Web tier forwards requests to App tier through internal ALB.
- App tier communicates with RDS MySQL database.
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit changes (
git commit -m 'Add new feature') - Push to branch (
git push origin feature/new-feature) - Open a Pull Request
This project is licensed under the MIT License.