Automating Route53 Failover S3
Utilising Route 53 DNS Failover with S3 Hosting is a smart idea for website resiliency in a disaster scenario (or temporary platform unavailability!).
Let’s start with a Route53 Hosted Zone File including three records. NS, SOA by default and a single A Record perhaps pointing to an EC2 instance or alias to a load balancer.
Now create a healthcheck where we can point to a cloudwatch alarm. Something like count of active nodes on an ELB or lack of HTTP500 status checks make sense.
Modify your A record ttl to 60seconds, Routing Policy of “Failover”, Failover type to “Primary” and associate with the healthcheck created in the step above.
Add a second A Record, ttl 60seconds, Routing Policy of “Failover”, Failover type to “Secondary”, evaluate target health to “No”, Associate with Health Check “No”.
The result should look like this
And finally health check should appear green, it’s a good idea to test the whole failover process by inverting the status on the healthcheck to simulate a downtime event and then revert back to healthy status.
Happy days.