AWS Builder Center
Building a Secure and Highly Available AWS Three-Tier Architecture

Building a Secure and Highly Available AWS Three-Tier Architecture

A practical look at designing a three-tier application architecture on AWS using VPC, public and private subnets, ALB, EC2 Auto Scaling, RDS, NAT Gateway, IAM, and Route 53.

Introduction

When I started learning AWS architecture, one of the concepts I wanted to understand properly was the three-tier architecture.
Instead of putting everything on one server or in one subnet, a three-tier architecture separates the application into different layers.
This makes the environment easier to manage and helps improve security, scalability, availability, and maintainability.
For this architecture, I focused on these AWS services:
  • Amazon VPC
  • Public and Private Subnets
  • Application Load Balancer
  • Amazon EC2
  • Auto Scaling
  • Amazon RDS
  • NAT Gateway
  • IAM
  • Amazon Route 53
The simplified architecture looks like:
Users → Route 53 → ALB → EC2 → RDS
with the network designed using public and private subnets.



1. Amazon VPC – The Network Foundation

The first step is creating an Amazon VPC.
The VPC provides an isolated network where the application resources can run.
Inside the VPC, I would divide the infrastructure into multiple Availability Zones to improve availability.
A simplified design could be:
VPC
|
+------------+------------+
| |
Availability Zone A Availability Zone B
| |
Public Subnet Public Subnet
Private App Subnet Private App Subnet
Private DB Subnet Private DB Subnet
Using multiple Availability Zones helps avoid depending on a single location for the entire application.



2. Public and Private Subnets

One of the most important concepts I learned is that not every resource needs to be publicly accessible.

Public Subnet

The public subnet can contain resources that need direct internet connectivity, such as:
  • Application Load Balancer
  • NAT Gateway

Private Application Subnet

Application servers such as EC2 instances can be placed in private subnets.
They don't need to have public IP addresses because users access the application through the Load Balancer.

Private Database Subnet

The RDS database should normally be placed in private subnets and should not be directly accessible from the internet.
This creates a separation between the public-facing layer and the internal application/database layers.



3. Route 53 – DNS Layer

When a user enters a domain such as:
https://example.com
Amazon Route 53 can be used to resolve the domain and direct traffic to the application's endpoint.
The basic flow is:
User
↓
Route 53
↓
Application Load Balancer
This provides a clean DNS entry point for the application.



4. Application Load Balancer

The Application Load Balancer (ALB) sits between the users and the application servers.
Instead of users connecting directly to EC2 instances, traffic goes through the ALB.
ALB
/ \
↓ ↓
EC2-1 EC2-2
The ALB can distribute requests across healthy EC2 instances.
It can also perform health checks to determine whether application instances are available.
This becomes especially useful when we have multiple EC2 instances running across Availability Zones.



5. EC2 – Application Tier

The application servers can run on Amazon EC2 instances in private subnets.
For example:
ALB
/ \
/ \
EC2-A EC2-B
AZ-A AZ-B
The EC2 instances don't need to be directly exposed to the internet.
Instead:
Internet → ALB → EC2
This reduces the public attack surface and creates a cleaner architecture.



6. Auto Scaling – Handling Traffic

Traffic isn't always constant.
During normal periods, we might need only a few EC2 instances.
During high traffic, additional capacity may be required.
This is where EC2 Auto Scaling becomes useful.
For example:
Low Traffic
↓
2 EC2 instances

High Traffic
↓
4 EC2 instances
Auto Scaling can launch additional instances when demand increases and remove unnecessary capacity when demand decreases, based on the configured scaling policies.
It can also replace unhealthy instances.



7. NAT Gateway – Outbound Internet Access

Another important part of the architecture is the NAT Gateway.
If EC2 instances are in private subnets, they may still need outbound internet access for tasks such as:
  • Installing packages
  • Downloading updates
  • Accessing external APIs
  • Pulling required resources
Instead of giving the EC2 instances public IP addresses, the private subnet can route outbound traffic through a NAT Gateway.
The flow becomes:
Private EC2
↓
Private Route Table
↓
NAT Gateway
↓
Internet Gateway
↓
Internet
The important point is that the NAT Gateway provides outbound connectivity for private resources; it does not make those private EC2 instances directly reachable from the internet.



8. Amazon RDS – Database Tier

The database is the final major layer.
Amazon RDS can be deployed in private database subnets.
The application servers communicate with RDS:
EC2
↓
RDS
But users should not connect directly to the database.
A simplified security flow is:
Internet
↓
ALB
↓
EC2
↓
RDS
Security Groups can be configured so that the database accepts connections only from the appropriate application security group.
This is much safer than exposing the database to the public internet.



9. IAM – Access Control

Security isn't only about networking.
AWS IAM controls who and what can access AWS resources.
For example, an EC2 instance may need permission to access an S3 bucket or another AWS service.
Instead of storing AWS access keys inside the application, an IAM role can be attached to the EC2 instance.
The principle I try to follow is:
Give only the permissions that are actually required.
This is known as the principle of least privilege.



10. Security Groups

Security Groups provide another important security layer.
A simple example could be:
Internet
↓
ALB Security Group
↓
EC2 Security Group
↓
RDS Security Group
For example:
ALB SG
  • Allow HTTP/HTTPS from the required sources.
EC2 SG
  • Allow application traffic only from the ALB security group.
RDS SG
  • Allow database traffic only from the application security group.
This creates controlled communication between the different tiers.



Complete Architecture

The overall architecture can be represented as:
Internet Users
|
↓
Amazon Route 53
|
↓
Application Load Balancer
/ \
/ \
↓ ↓
EC2 - AZ A EC2 - AZ B
| |
+--------+---------+
|
Amazon RDS
Private DB Subnets
For outbound access:
Private EC2
|
↓
Private Route Table
|
↓
NAT Gateway
|
↓
Internet Gateway
|
↓
Internet



End-to-End Request Flow

Let's look at what happens when a user opens the application.

Step 1 – User Request

The user enters:
https://example.com

Step 2 – DNS Resolution

Route 53 resolves the domain.

Step 3 – Load Balancing

The request reaches the Application Load Balancer.

Step 4 – Health Check

The ALB determines which application targets are healthy.

Step 5 – Application

The ALB forwards the request to an EC2 instance in the private application subnet.

Step 6 – Database

If the application needs data, the EC2 instance communicates with RDS.

Step 7 – Response

The response travels back through the application and ALB to the user.
So the simplified request path is:
User → Route 53 → ALB → EC2 → RDS



Why Use a Three-Tier Architecture?

The main benefits are:

🔐 Security

Resources can be separated into public and private network layers.

📈 Scalability

EC2 Auto Scaling can increase or decrease application capacity based on demand.

🛡️ High Availability

Resources can be distributed across multiple Availability Zones.

🔧 Maintainability

Each layer has a specific responsibility.

🌐 Controlled Internet Access

Private application servers can use NAT Gateway for outbound connectivity without being directly exposed to the internet.

🗄️ Database Protection

RDS can remain in private subnets and accept traffic only from authorized application resources.



What I Learned

The biggest thing I learned from studying this architecture is that AWS architecture is about separating responsibilities.
Instead of:
Internet → EC2 → Database
we can design:
Internet → Route 53 → ALB → Private EC2 → Private RDS
and add supporting services such as:
Auto Scaling → Scalability
NAT Gateway → Private outbound connectivity
IAM → Access control
Security Groups → Network-level access control
This makes the architecture much easier to secure, scale, and operate.



Final Thoughts

A three-tier architecture is a great foundation for understanding how production applications can be designed on AWS.
The services themselves are important, but understanding how they communicate with each other is even more important.
My current focus is continuing to improve my skills in:
AWS | DevOps | Terraform | Docker | Kubernetes | CI/CD | Prometheus | Grafana | Cloud Security
I'm looking forward to building more hands-on projects and sharing what I learn with the AWS community.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article