Skip to content

Overview

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.
is a simplified deployment model for Amazon ECS. It lets you deploy stateless HTTP/HTTPS containers without provisioning separate ALB, target group, listener, or auto scaling resources.

Your entire service infrastructure becomes one Terraform resource:

main.tf
resource "aws_ecs_express_gateway_service" "this" {
service_name = "my-service"
cluster = aws_ecs_cluster.this.arn
task_definition = aws_ecs_task_definition.this.arn
infrastructure_role_arn = aws_iam_role.infrastructure.arn
primary_container {
container_name = "app"
container_port = 8000
health_check_path = "/health"
}
network_configuration {
subnets = aws_subnet.public[*].id
security_groups = [aws_security_group.web.id]
access_type = "PUBLIC"
}
scaling_target {
auto_scaling_metric = "CPU"
auto_scaling_target_value = 70
min_task_count = 1
max_task_count = 4
}
}

That’s it. No ALB resource, no target group, no listener rules, no scaling policies.

This walkthrough documents a working project: a Bedrock
AWS fully managed service providing foundation models for generative AI applications.
-powered image analysis API that:

  1. Runs a FastAPI container with a /health endpoint and Swagger UI at /docs
  2. Accepts image uploads and returns AI-generated descriptions via Foundation Model
    A pre-trained large language or multimodal model available through Amazon Bedrock.
  3. Deploys to a public HTTPS endpoint with auto scaling and health-check-driven rollback
  4. Uses a single terraform apply to provision the entire stack
ResourcePurposeFile
aws_ecs_express_gateway_serviceService with managed ALB, scaling, health checksmain.tf
aws_ecs_clusterFargate-backed clustermain.tf
aws_ecs_task_definitionContainer image, port, environmentmain.tf

aws_vpc + subnets

Network with public subnets and IGWmain.tf
aws_security_groupVPC CIDR ingress on container portmain.tf

aws_iam_role (×3)

Task execution, infrastructure, task rolesmain.tf
SectionContent
ECS Express Mode

Concepts, Express Gateway Service resource, auto scaling, health checks

IAM RolesThree-role model, trust policies, Bedrock permissions
Networking

VPC layout, security groups, public subnets, ingress configuration

DeploymentTerraform apply, verifying health, accessing the web UI
TroubleshootingRollback loops, health check failures, common root causes