Mapping multiple Route53 record sets to a record set

29 / Jan / 2014 by Hitesh Bhatia 0 comments

Lets take an example where we need to point somedns.com, www.somedns.com to anotherdns.com using AWS’ Route53.

Creating a record set to point www.somedns.com to anotherdns.com is easy, where www.somedns.com would be a CNAME type record with value “anotherdns.com”. But mapping somedns.com to anotherdns.com is not that trivial as R53 does not allow creation of a CNAME record at the top node of a DNS namespace (aka the zone apex). Which basically means that we cannot create a CNAME record for zone apex somedns.com.

The answer to this might be creating an A type record which points to same IP address as anotherdns.com. This might not be an issue when you have a couple of hosted zones with very minimal record sets. But for bigger projects there can be many hosted zones with multiple record sets where maintenance of these records would become an issue.

A better and more manageable way to do this would be via S3 bucket. Below are the steps to do same.

1. Create an S3 bucket with name “somedns.com”.
2. Redirect all requests to another host name (www.somedns.com) for this bucket.

In this step we are asking AWS to do a permanent redirect on all incoming requests for bucket named “somedns.com” to “www.somedns.com”.


3. Point www.somedns.com to anotherdns.com.

We have already redirected all requests for somedns.com to www.somedns.com in step 2. And now we create a CNAME type record that would permanently redirect all requests that are targeted to www.somedns.com to anotherdns.com.

4. Create an ALIAS type record for somedns.com that points to bucket created in step 1.

Finally we tell AWS to send all incoming requests on somedns.com to bucket named somedns.com which would redirect all requests to www.somedns.com and which would ultimately send all requests to www.anotherdns.com.

These steps basically allowed us to bypass the limitation where creation of CNAME type record is not allowed for the zone apex. The whole architecture is described in following image.

FOUND THIS USEFUL? SHARE IT

Leave a comment -