3-tier web app on a VPC
The classic container web app: an Application Load Balancer in front of an autoscaling ECS Fargate service, backed by RDS for durable data and ElastiCache (Redis) for sessions and caching — all inside a VPC across two availability zones.
Build it
Section titled “Build it”- Drop a VPC with two subnets (Flowright wires the VPC plumbing — IGW, route tables, NAT).
- Add an ALB and connect the Internet entrypoint to it.
- Add an ECS Fargate service; wire the ALB’s target-group socket to it. Set
autoScaling,targetCpuPercent, andmin/maxCapacity— these drive both the generatedaws_appautoscaling_*resources and the simulator. - Add an RDS instance; wire it to the service’s database socket and put it on the private subnets.
- Add ElastiCache (Redis) for caching/sessions and wire it to the service.
- Wire security groups so only the ALB reaches the service and only the service reaches the data tier.
Autoscaling is real
Section titled “Autoscaling is real”Because scaling config lives on the node, the generated Terraform includes the scaling target and policy, and the simulator reads the same numbers — so what you watch scale is what you’ll deploy.
resource "aws_ecs_service" "web" { name = "web" cluster = aws_ecs_cluster.main.id desired_count = 2 launch_type = "FARGATE" load_balancer { target_group_arn = aws_lb_target_group.web.arn container_name = "web" container_port = 8080 }}
resource "aws_appautoscaling_target" "web" { max_capacity = 10 min_capacity = 2 resource_id = "service/main/web" scalable_dimension = "ecs:service:DesiredCount" service_namespace = "ecs"}- Push traffic in the simulator and watch the service scale out, then settle.
- Add per-environment overrides so prod gets a larger instance class than dev.