Deploying a Three-Tier Architecture

Overview

A three-tier architecture provides a general framework for organizing traditional client/server applications into three logical tiers: the Web tier, the Application tier, and the Database tier. End users interact with the Web tier (for example: mobile apps, websites…), which provides the interface for users to view, modify, or submit information. The Application tier is responsible for processing user requests, translating user actions into business logic so that programs can process the data. Finally, the Database tier (Data tier) is where the information processed by the application is stored and managed.

The cfn-aws-three-tier-demo.yaml template creates the entire architecture below. The main parameters are EnvironmentName, KeyPair, DatabaseName, MasterUsername, MasterUserPassword, SSHLocation, LatestAmiId, and the CIDR ranges of the VPC and subnets.

Web Tier

  • 2 public subnets (PublicSubnet1, PublicSubnet2) associated with the public route table, reaching the Internet through the Internet Gateway.
  • Internet-facing Application Load Balancer with a Security Group that allows HTTP (port 80) from the Internet.
  • Auto Scaling Group with 2–3 EC2 instances t3.micro running Amazon Linux 2023, bootstrapped with a static web page that shows the instance’s Availability Zone.
  • The EC2 Security Group allows HTTP from the Web Tier Application Load Balancer and SSH from the Bastion Host.
  • NAT Gateway placed in PublicSubnet1 so that private subnets can reach the Internet.

Application Tier

  • 2 private subnets (PrivateSubnet1, PrivateSubnet2) associated with the private route table, reaching the Internet through the NAT Gateway.
  • Internal Application Load Balancer with a Security Group that only allows HTTP from the Web Tier EC2 instances.
  • Auto Scaling Group with 2–3 EC2 instances t3.micro.
  • The EC2 Security Group allows HTTP from the Application Tier Application Load Balancer and SSH from the Bastion Host.

Database Tier

  • 2 private subnets (PrivateSubnet3, PrivateSubnet4) associated with the private route table.
  • Amazon RDS for MySQL 8.4 (db.t3.small) with a Multi-AZ standby instance.
  • The Database Security Group only allows port 3306 from the Application Tier and Bastion Host Security Groups.

Bastion Host

  • 1 public subnet (PublicSubnet3) associated with the public route table.
  • 1 EC2 instance t3.micro with nmap and the MySQL client (mariadb105) preinstalled.
  • The Security Group allows SSH from the IP range in the SSHLocation parameter.
  • The Bastion Host is allowed to SSH into the Web Tier and Application Tier and to connect to the Database Tier.

Outputs

  • BastionHostPIP: the public IP address of the Bastion Host.
  • WebTierLoadBalancerURL: the DNS name of the Web Tier Application Load Balancer.
  • AppTierLoadBalancerURL: the DNS name of the Application Tier Application Load Balancer.
  • MySQLDatabaseEndpointAddress: the endpoint of the RDS database.
  • MySQLDatabasePort: the port of the database.