A reference blueprint for building security-first, multi-AZ AWS platforms designed for fintech and high-trust production workloads. Every layer—from Cloudflare edge DNS and VPC networking to OpenBao/Vault secrets, immutable AMIs, and ECS/EKS services—is versioned as code using OpenTofu / Terraform, Packer, and Ansible.
Interactive Traffic & Access Flows
Use ▶ Play or select any scenario below to trace inbound client requests, internal private-subnet traffic, AWS VPC Endpoints, outbound NAT egress, and zero-trust operator access across Availability Zones.
Client HTTPS requests hit Cloudflare first, enter the VPC via the Internet Gateway, and land on the Public ALB inside the Public Subnets—where port 443 from Cloudflare IPs is the only exposed ingress and zero apps run. The ALB forwards traffic across the Private Subnet boundary to ECS/EC2 workloads launched with assign_public_ip = false (Task SG accepts only the ALB SG), which then talk to PostgreSQL, cache, and OpenBao.
Public Subnets: ALB (:443, Cloudflare SG) + NAT Gateways only — 0 apps Private Subnets: all apps & data; Task SG allows inbound only from ALB SG
Full Multi-AZ Network Blueprint
The complete scalable architecture below maps the Zones A–G pattern, showing inbound traffic (blue), outbound application egress (green), private AWS service connectivity via VPC Endpoints (dashed gray), CIDR allocation, and return paths.
Traffic Flows & Return Paths
ALBs, NAT Gateways, and Security Groups are stateful (return traffic automatically follows the reverse path), while Network ACLs (NACLs) are stateless and require explicit inbound/outbound return rules:
- Inbound (Client → App):
User → Cloudflare (WAF/TLS) → Internet Gateway → Public Subnet (ALB :443) → Private App—port 443 is the only port exposed on the Public Subnets (origin restricted to Cloudflare IPs vianbari/cloudflare-restrictor/aws/ mTLS / origin header), and the Public ALB targets private ECS/EKS/EC2 workloads directly across AZs. - Internal (Private Subnet):
Private App → Internal ALB/NLB → Target Service—internal load balancers handle private service-to-service traffic inside the VPC. - Outbound (App → Internet):
Private App → Same-AZ NAT Gateway (Elastic IP) → Internet Gateway → External API—unsolicited inbound connections through NAT are blocked by design. - Private AWS Connectivity (No NAT):
Private App → VPC Endpoints (Gateway & Interface) → S3 / ECR / ECS / KMS / CloudWatch / SSM / RDS & ElastiCache management APIs—keeps AWS control-plane and storage traffic on the AWS backbone (avoiding NAT data-processing costs), while database and cache data traffic stays directly on private subnets.
Multi-Account VPC & CIDR Scaling Pattern (Zones A–G)
Each environment (dev, staging, prod) runs in its own isolated AWS
account with a dedicated, non-overlapping 10.X.0.0/16 CIDR allocated from an
explicit CIDR registry / AWS VPC IPAM (for example, 10.10.0.0/16,
10.20.0.0/16, 10.30.0.0/16).
Non-overlapping CIDRs keep peering, Transit Gateway routes, security groups,
and VPC Flow Logs unambiguous across accounts. Each Availability Zone gets a
compact /24 public subnet for ingress/NAT and a large /21 private subnet
for compute and data growth (10.X.7.0/24 is reserved for future use):
| AZ | Public Subnet (/24) | Private App / Data Subnet (/21) | Typical Role |
|---|---|---|---|
| A | 10.X.0.0/24 | 10.X.8.0/21 | Primary active zone (provisioned by default) |
| B | 10.X.1.0/24 | 10.X.16.0/21 | HA active zone (provisioned by default) |
| C | 10.X.2.0/24 | 10.X.24.0/21 | Quorum / 3-AZ HA zone (provisioned by default) |
| D | 10.X.3.0/24 | 10.X.32.0/21 | Expansion zone |
| E | 10.X.4.0/24 | 10.X.40.0/21 | Expansion zone |
| F | 10.X.5.0/24 | 10.X.48.0/21 | Expansion zone |
| G | 10.X.6.0/24 | 10.X.56.0/21 | Expansion zone |
Domain Separation & Zero-Trust Operator Access
Customer-facing product domains and internal operational domains are kept strictly separate:
- Public product domains (
*.example.com) live on Cloudflare and terminate at the origin-restricted Public ALB. - Private infrastructure zones (
*.prod.example.net,*.staging.example.net,*.test.example.net) exist only in each account's private Route53 hosted zone.
Operator access is split cleanly across two audited paths—with zero public SSH ports or public admin UIs:
- Private DNS & internal services: Trusted operator devices use Tailscale
Split DNS to forward
*.example.netqueries to a reachable Route53 Resolver inbound endpoint / in-VPC DNS forwarder, while the encrypted tailnet carries access tovault.prod.example.netand internal metrics. - Interactive container access: Opt-in ECS Exec runs over IAM-authorized
AWS Systems Manager (
ssmmessagesVPC endpoint for NAT-free operation), streaming KMS-encrypted session transcripts to CloudWatch Logs (365-day retention) alongside authoritative CloudTrailExecuteCommandaudit events.
Repository Layout & Operational Patterns
.
├── cloudflare/ # Public DNS & edge rules (isolated state)
├── modules/ # Shared IaC modules (ecs_service, private_app, tailscale, alerts)
└── <env>-<account>/
├── openbao/ # Policies, auth methods, audit devices, signing integrations
└── <aws-region>/
├── packer/ # Immutable AMIs built with Packer + Ansible
└── terraform/
├── setup/ # One-time account & remote state bootstrap
├── vpc/ # Multi-AZ VPC, subnets, NAT, endpoints, IAM, alerting
├── services/ # Shared data tier (PostgreSQL, OpenBao storage, ECR)
└── applications/ # Load balancers, EC2 apps, and ECS Fargate services
Key operational practices baked into the platform:
- One file per service (clarity over DRY): Each ECS service lives in its
own file (
ecs_core_api.tf,ecs_worker.tf) instead of being merged into a singlefor_eachmap. That keeps diffs and code reviews tightly scoped to one service (while still reviewing the full OpenTofu/Terraform plan before every apply). - Reproducible operator environments: Tooling (
opentofu/terraform,awscli,packer,ansible,sops,openbao) is pinned withmiseinside a DevPod container, with per-accountdirenvprofiles and short-lived AWS IAM Identity Center (SSO) credentials—no long-lived static AWS keys. - Encrypted secrets & audited sessions: Repository-managed config is
encrypted with SOPS + age, runtime secrets live in OpenBao / Vault,
and broad read-only IAM roles are explicitly denied direct access to ECS Exec
audit transcripts and
ssm:StartSessionbypasses.
Need a security-first AWS or database platform like this for your team? Get in touch / Hire Me.