A CNAME pointing to 2 different A Records set up with Primary/Secondary Failover Routing?

Considering records like:

host.example.com as a CNAME to:

host01.example.com and host02.example.com

(on two separate records).

I want to set up those A records to be with a Failover routing policy.

Record Name      Type  Routing  Differentiator    Route traffic to
------------------------------------------------------------------
host.example.com CNAME Failover Primary         host01.example.com
host.example.com CNAME Failover Secondary       host02.example.com 

If host01.example.com is down for whatever reason, I want requests to host.example.com to still be satisfied, but just pointing to host02.example.com. Is this the correct way to implement such a policy in Route 53? Or would there be a better solution?


Solution 1:

host.example.com as a CNAME to: host01.example.com and host02.example.com

That is not possible, as you can not have 2 CNAME records on the same name. (as you can not have a CNAME record to cohabit with any other records for that matter - except DNSSEC ones).

If host01.example.com is down for whatever reason, I want requests to host.example.com to still be satisfied, but just pointing to host02.example.com.

The DNS does not work like that. By default, it provides load balancing, not failover. You can have various partial ways by using short TTLs, dynamic DNS to change IP addresses quickly, DNS anycast, rotating IP addresses in response, or then more importantly handle the problem at the next layer where it makes sense like HTTPS or something else. All load-balancers provide fail-over mechanisms (but then you also have to find out how to have fail-over for the load-balancers themselves).

For "hard" DNS cases to handle, look at dnsdist, that you can put in front of some authoritative nameserver but which enables you far richer way to construct replies.