Looking for a "best practice" answer to managing externally-addressable hosts using the combination of Amazon EC2 and Amazon Route 53, without using Elastic IPs for each host. In my scenario I will have 30+ hosts that need to be accessible from outside EC2, so directly using internal DNS will not work.
In the past, I have addressed hosts by assigning an elastic IP to that host (let's say, 220.127.116.11) and then creating an associated A record. For example, let's say I want to create "ec2-corp01.mydomain.com" I might do:
ec2-corp01.mydomain.com. A 18.104.22.168 300
Then on that EC2 instance, I would assign the Elastic IP of 22.214.171.124, and everything works fine. Of course, to make this work, I need to have one Elastic IP per instance, which is something I'd like to avoid if possible; I'd like the infrastructure to be more dynamic.
So my thought is to try something like:
Create a script that queries the internal EC2 tools to determine an instance's private hostname
On instance boot, call that script to determine its hostname, and then using the command-line Route 53 interface to find and update that hostname to its current internal hostname
Since the host will have a relatively low TTL (let's say 300 as above, or 5 minutes) it should take effect pretty quickly
Is this a good idea? Is there a better or more widely accepted way to handle it?
If it IS a good idea, what type of record should I be creating? A CNAME that points to the internal host, like ec2-55-55-55-55.compute-1.amazonaws.com? Is an A record better or worse?