title: "Strategic Success: Executing a 5-Layer Infrastructure Stack" date: "MAR 29, 2026" id: "LAB-05"
AWS 5-layer Infrastructure stack
https://github.com/hcc2git/aws_formbriks_infra.git

Legend/Layers:
🌐 Top Layer: Public Internet (The User)
☁️ Core Box: AWS Region (eu-north-1) - Custom VPC (10.0.0.0/16)
🏷️ Left Side: Layer 01: Networking & Security
🏷️ Top Center: Layer 02: Compute Cluster
🏷️ Bottom Center: Layer 03: Data Tier
🏷️ Right Side: Layer 05: Event Engine
📄 Subnets (Layer 01):
🟩 Public Subnets (A & B)
🟪 Private Subnets (A & B)
System Flow (The Blue Arrow Path):
Request: User traffic enters via the 🌐 Internet Gateway (IGW).
Entry: Traffic hits the 🎯 Application Load Balancer (ALB) (Layer 02) in the Public Subnet.
Routing: The ALB routes traffic across AZs to the 📦 Formbricks ECS Fargate Tasks (Layer 04) running in the Private Subnets.
Data Operations: The Formbricks containers communicate with the 🗄️ RDS PostgreSQL and 🚀 ElastiCache Redis (Layer 03), also secured in the Private Subnets.
Outbound Pulls (Crucial Workaround): The Fargate tasks pull the Docker image via the 🛡️ NAT Gateway (Layer 01), which is necessary because they have no IAM role to use an ECR endpoint.
Event Webhook: When a survey is submitted, Formbricks triggers a POST request to the ⚡ API Gateway (HTTP API) (Layer 05).
Buffering: The API Gateway integrates directly with the 📬 SQS Queue, which buffers the incoming survey data.
Asynchronous Processing: The ⚙️ AWS Lambda function (Layer 05), using the hard-coded LabRole, is triggered to consume and process messages from the SQS queue.
External Integration (Potential): The Lambda function logs the data, effectively completing the event-driven chain. ]