Search code examples
amazon-web-servicesamazon-ec2dnsamazon-route53wildcard-subdomain

Each wild card sub-domain points to different IP address


I have been using AWS Route-53 as dns service for my application and say in my code, for every http request I have a requirement of creating some dynamic sub-domains and point it to the new ec2 instance that gets created on fly.

Any one should now be able to use the newly created sub-domain to make requests to the newly created ec2 instance.

I knew I could use wildcard dns record, but does it not just point to one single IP?

How could I make every sub-domain that was created to always point to the new ec2 instance?


Solution

  • traefik is exactly what I needed. I configured traefik with etcd as it's provider and just by making entries to etcd server, I could achieve what I wanted.

    Now I just have a wild card domain mapped to an ec2 instance on which I run traefik which watches etcd server for any new entries with /traefik/ as it's prefix. It then dynamically generates new configuration and takes care of routing any request to the destination server based on the HOST header.