Skip to content

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.

🌐 Internet
Public subnets
ECS Gateway ALBHTTPS · host-based routing
Private subnets
Orders

service -a · awsvpc task

Catalog

service -b · awsvpc task

ECS-optimized EC2 instancecapacity for the tasks above

NAT gateway → Internet

PieceWho owns it
VPC, public/private subnets, NAT, gateway infra role, task execution roleShared setup
Cluster, gateway, EC2 instance, servicesThis 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).

EC2 capacity