EC2 overview
This path runs ECS services on EC2 launch type behind an ECS Gateway. It uses the shared VPC and IAM roles from Setup, then builds everything else for this path alone.
You deploy the same two demo apps as the Fargate path — Orders (service -a) and Catalog (service -b) — so each managed hostname clearly shows which service the shared ALB routed to. The difference here is compute: tasks run on an ECS-optimized EC2 instance you manage, not on Fargate.
Architecture (high level)
Section titled “Architecture (high level)”service -a · awsvpc task
service -b · awsvpc task
NAT gateway → Internet
| Piece | Who owns it |
|---|---|
| VPC, public/private subnets, NAT, gateway infra role, task execution role | Shared setup |
| Cluster, gateway, EC2 instance, services | This path (${NAME}-ec2) |
Platform creates the gateway on the public subnets and associates the cluster. Application services only add a gateway connector and place tasks in the private subnets. ECS provisions the ALB, certificates, hostnames, and target groups.
The container instance is capacity only and also runs in a private subnet. Tasks use awsvpc (required by Gateway).