DEV Community

Cover image for AWS Three-Tier Architecture
Hema
Hema

Posted on

AWS Three-Tier Architecture

πŸš€ Deploying a Scalable Web Application on AWS

In this article, we'll walk through the complete setup and deployment of a scalable, production-ready web application on AWS. We'll cover everything from architecture, networking, EC2, database, load balancers, and auto-scaling. By the end, you'll have a fully functional, auto-scaled web application deployed on AWS.


🟣 PART 1 β€” Architecture & Initial Setup

βœ… Architecture Overview

Architecture


βœ… 1. Download Code from GitHub

Clone the GitHub repository containing the application code.

Download Code


βœ… 2. Create an S3 Bucket

Navigate to S3 Service > Create Bucket.

S3 Bucket


βœ… 3. IAM Role for EC2-S3 Communication

Go to IAM > Roles > Create Role.

Select EC2 and attach the following policies:

  • AmazonSSMManagedInstanceCore
  • AmazonS3ReadOnlyAccess

IAM Role


🟣 PART 2 β€” Networking & Security

βœ… 1. VPC Creation

Go to VPC Dashboard > Your VPCs > Create VPC.

VPC Creation


βœ… 2. Subnet Creation

Create 6 subnets across two Availability Zones for high availability.

Subnet Creation


βœ… 3. Internet Gateway

Create and attach an Internet Gateway to the VPC for public subnet internet access.

Internet Gateway


βœ… 4. NAT Gateway

Create NAT Gateways in your public subnets for private subnets to access the internet.

NAT Gateway


βœ… 5. Routing Configuration

Set up route tables and associate subnets properly.

Route Table


βœ… 6. Security Groups

Define security groups for EC2 and Load Balancers to control traffic.

Security Group


🟣 PART 3 β€” Database Deployment

βœ… 1. Subnet Group for RDS

Create an RDS Subnet Group using private subnets.

Subnet Group


βœ… 2. Database Creation

Create your RDS database instance.

Database Deployment


🟣 PART 4 β€” Application Deployment

βœ… 1. Launch App Instance

Launch an EC2 instance for your App Tier.

Launch Instance


βœ… 2. Connect to Instance

Use Session Manager to connect to your instance securely.

Connect to Instance


βœ… 3. Configure Database Connection

Configure database credentials for the application.

Configure Database


βœ… 4. Configure App Instance

Update your app-tier to use correct database and S3 details.

Configure App

Upload your app-tier code to S3.

Upload App Tier


βœ… 5. Test App

Ensure the app-tier is working correctly.

Test App


🟣 PART 5 β€” Internal Load Balancer & Auto Scaling

βœ… 1. App Tier AMI

Create an AMI from your configured App Instance.

Create AMI


βœ… 2. Create Target Group

Target Group


βœ… 3. Internal Load Balancer

Deploy an internal Load Balancer.

Internal Load Balancer


βœ… 4. Launch Template

Create a Launch Template with the AMI.

Launch Template


βœ… 5. Auto Scaling Group

Set up Auto Scaling for your App Tier.

Auto Scaling


🟣 PART 6 β€” Web Instance Deployment

βœ… 1. Update Config File

In the nginx.conf, replace [INTERNAL-LOADBALANCER-DNS] with your internal load balancer DNS.

Update Config


βœ… 2. Launch Web Instance

Launch Web Instance


βœ… 3. Connect to Instance

Connect Web Instance


βœ… 4. Configure Web Instance

Install necessary packages and configure the web-tier.

Configure Web


🟣 PART 7 β€” External Load Balancer & Auto Scaling

βœ… 1. Web Tier AMI

Create an AMI from your web instance.

Web AMI


βœ… 2. Target Group

Target Group


βœ… 3. Internet-Facing Load Balancer

Deploy an Internet-Facing Load Balancer.

Internet Load Balancer


βœ… 4. Launch Template

Launch Template


βœ… 5. Auto Scaling Group

Configure Auto Scaling for the Web Tier.

Auto Scaling Web


βœ… πŸŽ‰ Final Result

Congratulations! Your highly available, auto-scaled, and load-balanced Web Application is ready πŸš€

Web App


πŸ’‘ Feel free to drop your questions or suggestions in the comments. Happy Deploying! 🌐


Top comments (0)