The three-tier VPC is the layout most production workloads start from. Only the load balancer lives in public subnets; application servers sit in private subnets and reach the internet through NAT; databases sit in a data tier that accepts traffic from the application tier and nothing else. Every tier is duplicated across at least two availability zones.
- Detect
- Analyze
- Resolve
When to use it
- Web applications and APIs with a database behind them
- Teams that want a clear blast radius per tier
- Any workload that needs to survive the loss of one zone
When to avoid it
- Single-instance dev sandboxes where cost matters more than uptime
- Fully serverless stacks that never place resources in a VPC
How traffic flows
- Requests arrive through the internet gateway and terminate on the load balancer in the public subnets.
- The load balancer forwards to healthy application targets in both zones. Health checks remove a failed target within seconds.
- Application servers connect to the primary database on its private address. The standby in the second zone receives synchronous replication and is promoted if the primary fails.
- Outbound calls from the application tier (package updates, third-party APIs) leave through a NAT gateway, so no server needs a public address.
Configuration examples
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"
name = "prod"
cidr = "10.0.0.0/16"
azs = ["us-west-2a", "us-west-2b"]
public_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
private_subnets = ["10.0.11.0/24", "10.0.12.0/24"]
database_subnets = ["10.0.21.0/24", "10.0.22.0/24"]
enable_nat_gateway = true
one_nat_gateway_per_az = true # no cross-zone dependency for egress
create_database_subnet_group = true
enable_flow_log = true
create_flow_log_cloudwatch_log_group = true
create_flow_log_cloudwatch_iam_role = true
}resource "aws_security_group" "app" {
name = "app"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
security_groups = [aws_security_group.alb.id] # only the load balancer
}
}
resource "aws_security_group" "db" {
name = "db"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
security_groups = [aws_security_group.app.id] # only the app tier
}
}Examples are starting points. Review provider limits, names and versions for your environment before applying.
What to monitor
| Signal | Why it matters |
|---|---|
| Healthy target count per zone | A zone with zero healthy targets means all traffic is riding on the other zone. |
| Load balancer 5xx and target response time | The first visible symptom of an application or database problem. |
| NAT gateway port allocation errors | Connection-heavy workloads exhaust NAT ports and outbound calls start failing silently. |
| Database replica lag | A standby that is minutes behind is not a safe failover target. |
| Security group changes | An inbound rule opened to 0.0.0.0/0 on the data tier is a critical finding. |
Common failure modes
One NAT gateway for both zones
If that zone fails, the surviving zone loses all outbound access.
Sentinel flags the shared dependency during the configuration audit.
Database tier reachable from the public subnets
A permissive rule makes the database one hop from the internet.
Sentinel detects the rule change and raises a critical finding with the exact rule.
Health check pointed at a static page
Targets look healthy while the application behind them is failing.
Lens correlates rising 5xx responses with healthy-target counts and flags the mismatch.