Move Aside Route 66, Route 53 is the New Game in Town
On the first day I started working with AWS (Amazon Web Services) I provisioned a few EC2 (Elastic Compute) Linux instances and I thought I was well on my way to being a cloud expert. I was sure in for a surprise! I set up an FTP server, a web server, and a few other options and was just playing around in the environment. I felt pretty good by the end of the day. I shut down my instances to save costs and wrapped things up for the evening. At that moment I had no clue I was going to have a mess on my hands in the morning.
When tomorrow arrived I enthusiastically sat down and fired my instances back up. Nothing worked! After a bit of investigating I realized that all of my machines had new IP addresses on them. I had simply put in IP addresses rather than hostnames in my config files across the environment. I figured I would just replace the IP addresses with hostnames and be on my way. I did that and everything worked fine the rest of the day. The next day was déjà vu all over again. Nothing worked! Again, I had to investigate. I realized that not only do the IP addresses change, but the hostnames do as well.
Moving to static hostnames was a relatively simple task but I now had some serious thinking to do here regarding name resolution. My first reaction was to just install my own DNS server and use dynamic DNS updates. There was one problem; my DNS server wouldn’t have a static IP address either.
This is when it hit me that I needed to really start to think differently about how things work in the cloud. I hit the books and read up on what AWS has to offer.
Luckily AWS had exactly what we needed. Their scalable DNS service, Route 53 has an API available that lets you communicate from your instance directly to Route 53 without knowing the IP address or hostname of the DNS server. Through a connection secured by Amazon’s IAM (Identity and Access Management) you can issue Route 53 commands to register DNS entries.
With this cloud API I was able to write a small script to register servers with Route 53 when they boot and also tidy up a few other items such as the hosts file. In fact, the server registers itself twice; once for an internal name and another time for an external name.
With less than 10 lines of scripting we now have an environment that seamlessly reconfigures itself every time it’s restarted.
If you would like to see the scripts that we put together or have a more technical question about how exactly this works please feel free to contact our team.