I'm searching for a way to add a domain name to an ECS service (EC2 not Fargate).
To be clear I'm looking for a solution which DNS resolves a domain name A or AAAA name (possibly CNAME if it and points to an A or AAAA). It doesn't matter to me which network mode this works for. The container can be placed in any of host
, bridge
, awsvpc
if the solution works!
awsvpc
is not viable outside of Fargate
Solutions requiring AWS VPC seem to be incompatible with ECS/EC2 and only viable for Fargate. Reason here:
Each Amazon ECS task that uses the awsvpc network mode receives its own elastic network interface (ENI), which is attached to the Amazon EC2 instance that hosts it. There's a default quota for the number of network interfaces that can be attached to an Amazon EC2 Linux instance. The primary network interface counts as one toward that quota.
So a t3.medium
can run only 2 tasks and even a t3.2xlarge
can only run 3 (limits here)
Service discovery is not viable
Service Discovery will only add SRV type DNS records for host
and bridge
type network containers. Most software we run does not understand SRV records. We need A and AAAA records.
Service Discovery will create A and AAAA records for awsvpc
network type containers... back to awsvpc
not being viable.
AWS App Mesh is not viable
We tried setting up app mesh and were almost immediately told our tasks need to be awsvpc
¯\(ツ)/¯
Load balancers appear to be unviable
This might work for some services. But then we fall down big holes either where the service is not HTTP or the service requires clients be authenticated with SSL client certificates.
Creating many IP load balancers for non HTTP / client SSL services is cost prohibitive.
<rant>
AFAIK, Kubernetes would have made this trivial. Even docker swarm has this. I'm really shocked how many hours we've spent searching for this one trivial thing.<\rant>
Question
How to add a domain name to an ECS/EC2 container without a load balancer?