Search code examples
amazon-web-servicesamazon-cloudfrontamazon-ecs

Pointing AWS CloudFront to ECS with Route53 SRV


I was wondering how to point AWS CloudFront to AWS ECS Container using Service Discovery (Route 53 with SRV Record).

ECS is based on Spot EC2 with no Load Balancer.


Solution

  • The suggested approach for an architecture running on a container is to have traffic to the container forwarded from a AWS ELB.

    If you're using ECS with service discovery then the record being written is actually written to a private hosted zone which is not accessible outside of the VPC(s) it is attached to.

    Furthermore containers are ephemeral, with a risk further increased by using a spot instance that the container could be terminated at any point. If the instance is public facing it would need an Elastic IP address to be associated to it so that it could retain the IP address.

    You would want to create an A record to this EIP for CloudFront to be able to use it, this A record should have the value of a domain that CloudFront should resolve, and must be in a public hosted zone.

    Within your CloudFront distribution the origin value would be set to be the domain name that you setup in the previous step.