- Newest
- Most votes
- Most comments
Adding to the generated recommendation: The core issue here is that ECS Express Mode acts as a 'black box' regarding the underlying Load Balancer. While the suggestion to use the Console/CLI works, it breaks the CloudFormation automation (leading to drift).
If you must stick with CloudFormation and require a fully automated custom domain setup, consider these two technical paths:
- The "Standard" Route (Recommended): Move away from
AWS::ECS::ExpressGatewayServiceand use the standardAWS::ECS::Servicecombined with an explicitly definedAWS::ElasticLoadBalancingV2::LoadBalancer. This gives you full access to theCertificatesproperty of the Listener within the same template. - Route 53 Optimization: Instead of a
CNAMEfor theApiService.Endpoint, use an Alias Record (Type A). Alias records are better for AWS-native resources as they handle DNS resolution more efficiently and are not charged as standard queries by Route 53. - The Lambda Workaround: If you want to keep Express Mode, you could implement a CloudFormation Custom Resource (backed by a Lambda). This Lambda can use the AWS SDK to programmatically find the 'hidden' ALB created by Express Mode and attach the SSL certificate/Host-header rules during the stack deployment.
Summary: Express Mode prioritizes simplicity over configurability. For production-grade custom domain setups, the standard ECS resource path is currently the most robust way to keep everything within CloudFormation."
Based on the available documentation, configuring a custom domain with ECS Express Mode through CloudFormation is not currently supported in the same way as it is through the console. The process for adding a custom domain to an ECS Express Mode service requires manual configuration of the Application Load Balancer that is automatically created by Express Mode.
To add a custom domain, you need to:
-
Add your custom domain as a host header condition in the Application Load Balancer listener rule. This should use the same domain name you want to associate with your service (for example,
app.example.com). This configuration tells the Application Load Balancer to route traffic from your domain to the ECS Express Mode target group. -
Add the SSL certificate to the Application Load Balancer HTTPS listener. You'll need to add your ACM certificate to the HTTPS listener.
These configurations are currently done through the console or AWS CLI by modifying the Application Load Balancer resources that Express Mode creates automatically. The CloudFormation template you've provided for the AWS::ECS::ExpressGatewayService resource doesn't include properties for custom domain configuration, and the documentation doesn't show examples of managing the Application Load Balancer configuration through the Express Mode CloudFormation resource itself.
Your approach of using a Route 53 RecordSet to point to the Express Mode endpoint is correct for the DNS portion, but the Application Load Balancer configuration (host header condition and SSL certificate) would still need to be configured separately, either through the console, AWS CLI, or by managing the Application Load Balancer resources directly in CloudFormation outside of the Express Mode service definition.
Sources
AWS App Runner availability change - AWS App Runner
Migrating from AWS App Runner to Amazon ECS Express Mode | Containers
Relevant content
- asked a month ago
- AWS OFFICIALUpdated 2 years ago
