Avoiding downtime while switching CNAMEs with AWS's Route53

Dan Fried asked:

I’m trying to make a seamless transition from Heroku to AWS. Currently, DNS is being handled by Route53, with a CNAME record sending traffic to the heroku SSL subdomain. I need to change this to an A Alias record, pointing to the new Elastic Load Balancer with no service disruption.

If the initial record were an A record, then it would simply be a matter of creating the Alias A record, and then removing the original, so that there would always be an active A record for the given subdomain at all times. However, CNAMEs prevent any other records from being created for the same subdomain, with the following message:

<Message>RRSet of type A with DNS name www.example.com. is not permitted because a conflicting RRSet of type  CNAME with the same DNS name already exists in zone example.com.</Message></Error>

If I remove the CNAME record before creating the A record, then there will be a window during which expired TTLs will fail to resolve the site. How can I avoid this downtime?

My answer:

It appears you’re using the ChangeResourceRecordSets API call. Just send both changes at the same time: a CREATE for the A record and a DELETE for the CNAME record.

If this doesn’t work, yell at Amazon until they fix it.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.