Skip to content

VPC Layout

ECS Express Mode deploys its managed ALB and tasks into the subnets you provide. The VPC
Virtual Private Cloud — an isolated virtual network within AWS where resources are deployed.
must have DNS resolution enabled and an Internet Gateway
A VPC component that enables communication between resources in a VPC and the internet.
attached so the ALB can receive public traffic and tasks can pull container images.

This page documents the VPC layout used in the terraform-aws-ecs-express-mode-demo project — a minimal configuration with two Public Subnet
A subnet with a route to an Internet Gateway, enabling resources to have public IP addresses and internet access.
across availability zones, a single route table, and a default route to the internet.

The VPC
Virtual Private Cloud — an isolated virtual network within AWS where resources are deployed.
enables both DNS settings that ECS and the ALB require for service discovery and certificate validation:

main.tf
resource "aws_vpc" "this" {
cidr_block = "10.0.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
}
  • enable_dns_support — allows instances and services in the VPC to resolve public DNS hostnames
  • enable_dns_hostnames — assigns DNS hostnames to resources with public IPs, required for the ALB to receive a public DNS name

Without these settings, Express Mode cannot provision the ALB endpoint or resolve container image registries.

The Internet Gateway
A VPC component that enables communication between resources in a VPC and the internet.
provides the path between the VPC
Virtual Private Cloud — an isolated virtual network within AWS where resources are deployed.
and the public internet. Express Mode needs this for two reasons: the ALB must be reachable from external clients, and tasks need outbound access to pull images and reach AWS APIs.

main.tf
resource "aws_internet_gateway" "this" {
vpc_id = aws_vpc.this.id
}

Two Public Subnet
A subnet with a route to an Internet Gateway, enabling resources to have public IP addresses and internet access.
span different availability zones for high availability. Express Mode places both the ALB and tasks in these subnets:

main.tf
resource "aws_subnet" "public" {
count = 2
vpc_id = aws_vpc.this.id
cidr_block = cidrsubnet(aws_vpc.this.cidr_block, 8, count.index)
availability_zone = data.aws_availability_zones.available.names[count.index]
map_public_ip_on_launch = true
}

The map_public_ip_on_launch setting ensures that tasks launched in these subnets receive public IP addresses, enabling direct outbound internet access without a NAT gateway.

A route table with a default route to the Internet Gateway
A VPC component that enables communication between resources in a VPC and the internet.
makes the subnets public. Without this route, tasks cannot reach the internet and the ALB cannot serve external traffic:

main.tf
resource "aws_route_table" "public" {
vpc_id = aws_vpc.this.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.this.id
}
}
resource "aws_route_table_association" "public" {
count = 2
subnet_id = aws_subnet.public[count.index].id
route_table_id = aws_route_table.public.id
}

The Express Gateway Service
The aws_ecs_express_gateway_service Terraform resource that provisions an ECS service with managed ALB, auto scaling, and simplified configuration for HTTP/HTTPS web applications and APIs.
network_configuration block accepts one subnets list. Express Mode places both the managed ALB and your tasks into those same subnets. This simplifies configuration but limits network isolation options.

The type of subnets you pass to Express Mode determines the ALB’s accessibility and the access_type value:

Subnet TypeRoute to IGWALB Resultaccess_typeReachable From
Public Subnet
A subnet with a route to an Internet Gateway, enabling resources to have public IP addresses and internet access.
Yes (0.0.0.0/0 → IGW)Internet-facing ALBPUBLICThe public internet
Private subnetsNoInternal ALBPRIVATEWithin the VPC only

The demo project uses public subnets so the ALB is internet-facing and the application is accessible from anywhere. If you need an internal-only service, pass private subnets instead — but note there is no hybrid option with Express Mode.

VPC console showing subnets and route table

Express Mode needs each piece of this VPC
Virtual Private Cloud — an isolated virtual network within AWS where resources are deployed.
layout:

  • DNS support/hostnames — the managed ALB requires a resolvable public DNS name
  • Internet Gateway
    A VPC component that enables communication between resources in a VPC and the internet.
    + route
    — external traffic must reach the ALB, and tasks need outbound access for image pulls and AWS API calls
  • Two subnets in different AZs — ALB requires at least two subnets across availability zones for high availability
  • Public subnets with public IPs — tasks assigned public IPs can reach the internet directly without a NAT gateway, keeping the infrastructure minimal

Without any of these components, Express Mode cannot provision the Shared ALB
The Application Load Balancer shared by up to 25 Express services in the same VPC using Host header routing rules.
or launch healthy tasks.