amazon-web-servicesamazon-ec2dnsfqdn

AWS - Can I launch nodes under a DNS domain (Auto Scale Group)?


Use Case

I'm working on an application that uses Presto, and for Presto, I have to set up HTTPS traffic internally (for security compliance reasons).

For this, I preferably need the nodes' FQDN to be in the same domain. E.g. myhost1.mydomain.com, myhost2.mydomain.com.

My Question

AWS automatically gives a FQDN like ip-10-20-30-40.ec2.internal. So, my question is:

Is there a way I can have a new node automatically be created with a FQDN like myhost1.mydomain.com? I know I can create internal "hosted zones" and DNS records for my hosts pretty easily, but I can't figure out how to make that the default domain for a new host.

Also, just FYI, I'm doing this for an auto-scale group; but I suspect that's irrelevant.


Solution

  • When the Amazon EC2 starts, it can run a script passed in via User Data.

    You could code this script to create a CNAME record in Amazon Route 53 that points to the IP address of the instance.

    I'm not sure how you'd necessarily determine the number within the name, so you could just create a random name. Also, it might be tricky to remove the CNAME entry when the instance is terminated. One way to both assign and remove the record would be to use Amazon EC2 Auto Scaling Lifecycle Hooks, which allows code to be triggered outside of the instance itself. It's more complex but would be fully effective.