Auto updating Route53 DNS when you launch a new EC2 instance based on an AMI


I came across an issue with my DNS entries that mean every time that my spot instance was terminated, I had to manually change the A record.  That’s not very cloud-like.

Found an article(below):

The problem with the article, is that the API has changed since it was written and the script no longer works.

Steps 1-5 are spot on, and most of step 6 is perfect – aside from the script – my fixes are below, I’ve updated the api call and also added in a path statement so that the script will run non-interactively.

Following the blog above, If you are using an amazon linux ami as your base image, you’ll already have the awscli package so you can skip the first part of part 6 also.

 

=========

=========

 

Whilst this is great if you have tags in place, sometimes you want to have something hardcoded to update the DNS records quickly in case of failure/spot request going away.

=========

Share on: