Automatic public DNS for Fargate-managed containers in Amazon Elastic Container Service
Fargate-managed containers in ECS lack build-in support for registering services into public DNS namespaces (12/2018). This is an event-driven approach to automatically register the public IP of a deployed container in a Route 53 hosted zone.
See this blog post for more information.
A lambda function subscribes to an "ECS Task State Change" event. It gets called whenever a container has started up. What the function does is :
First you need to pull NodeJs dependencies using:
npm install
You need to have the Serverless Framework CLI installed.
Deploy the function in your active AWS account:
serverless deploy
In your ECS console, select your cluster and add the tags
Z1OAI7EUAR14MP
)foby.org
)Well, just start a Fargate task in your cluster. When the task has started up, the function creates an A-record-set in your hosted zone with the containers' service name as subdomain.