nodemethod
FoundationsFoundational

Three-tier VPC across two availability zones

Public, application and data subnets in two zones, so a single zone failure never takes the service down.

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.

VPC 10.0.0.0/16AVAILABILITY ZONE AAVAILABILITY ZONE Bsync replicationWWWInternetclientsGWInternet gatewayigwLBLoad balancerpublic subnetsGWNAT gatewayegressAPPApp servers10.0.11.0/24APPApp servers10.0.12.0/24DBPrimary database10.0.21.0/24DBStandby database10.0.22.0/24
traffictunnel / replicationblocked

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

  1. Requests arrive through the internet gateway and terminate on the load balancer in the public subnets.
  2. The load balancer forwards to healthy application targets in both zones. Health checks remove a failed target within seconds.
  3. 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.
  4. 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
}

Examples are starting points. Review provider limits, names and versions for your environment before applying.

What to monitor

SignalWhy it matters
Healthy target count per zoneA zone with zero healthy targets means all traffic is riding on the other zone.
Load balancer 5xx and target response timeThe first visible symptom of an application or database problem.
NAT gateway port allocation errorsConnection-heavy workloads exhaust NAT ports and outbound calls start failing silently.
Database replica lagA standby that is minutes behind is not a safe failover target.
Security group changesAn 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.

Checklist

0 of 6 done
Was this pattern useful?

Run this pattern with NodeMethod watching it.

NodeMethod is onboarding early-access teams now. Tell us about your environment and we will be in touch.

esc
↑↓ to move↵ to open