Updating Route53 records after EC2 instance restart

If you are not using Elastic IPs for your EC2 instances, chances are stopping and starting the server (as opposed to just restarting it) will result in different IPs after the instance comes back online. If you have A records pointing to those IPs in Route53 you will need a way to update them.
There are few different solution to work around this problem. I decided to whip up a quick script that runs from rc.local on EC2 instances that have the appropriate IAM role to update Route53 records. After the script is executed, it will automatically gather the new Public IP and update the DNS record for it in Route53. Hackish you say, perhaps, but it is a good primer on using the AWS CLI. The script follows: