Highly available multi region S3 website Cloudfront distributions
With the latest S3 outages more people are looking to make their S3 Cloudfront distributions more highly available. Which presents challenges due to Cloudfront not being designed to fail over when a origin is unavailable.
When S3 is having issues in a specific region like the recent outages in us-east-1 cloudfront cannot automatically fail over to your replica bucket in a secondary region. You also cannot use route53 dns fail over because S3 routing is based off of DNS and you cannot have multiple Cloudfront distributions with the same cname.
Using a route53 health check on the primary S3 bucket website endpoint you can trigger a lambda function to swap out the origin in your cloudfront distribution to the secondary(replica) S3 bucket in another region.
Note: this solution will not automatically fail back. This is by design because some of the issues with S3 in the past where intermittent until the system was stabilized
Note 2: Once Code is available on Github the post will be updated