Question: How do I configure my website to fail over to an S3 bucket when a Route 53 health check fails?

I want to set up a static endpoint that my dynamic website can fail over to in the event there’s an issue with my infrastructure.

Short descriptionBefore you get started, verify the following configurations:You have an active Amazon Route 53 hosted zone.You're hosting the dynamic version of your website on an Amazon Elastic Compute Cloud (Amazon EC2) instance.The Route 53 hosted zone is already successfully routing your website traffic to your Amazon EC2 instance.

ResolutionConfigure the hosted zone to fail over to a static website hosted in an Amazon Simple Storage Service (Amazon S3) bucket for unhealthy Route 53 checks. The static website is what users see when the hosted zone fails over. After your health check returns to healthy, the hosted zone automatically routes traffic to your primary endpoint. Follow the instructions for hosting a static website on Amazon S3.Note:When naming the bucket, be sure that the S3 bucket name is the same as the name of your record.Amazon S3 supports only the HTTP protocol. If your website uses HTTPS, then at failover the page displays the error "could not display this page". To serve HTTPS requests, see How do I use CloudFront to serve HTTPS requests for my Amazon S3 bucket?Create the Route 53 health checkOpen the Amazon Route 53 console, and then choose Health checks.Choose Create health check, and enter the following:For Name, enter a name for the health check.For What to monitor, choose Endpoint.For Specify endpoint by, choose IP address.For Protocol, choose HTTP.For IP address and Host name, enter the IP and hostname for your EC2 instance.For Port, choose 80.Leave Path empty, or specify the page that you want to check.Choose Next.For Create alarm, choose Yes.Choose Create health check.Note: For more information, see Creating and updating health checks.Create a record set for your primary endpointOpen the Amazon Route 53 console, and then choose Hosted zones.For Domain Name, choose the domain of the hosted zone that you want to create the record for.Choose Create record, and then create a record set with these values (for all other fields, use values that fit your use case):For Record Name, enter the name. Make sure that it's the same as the S3 bucket name.For Record type, choose A – Routes traffic to an IPV4 address and some AWS resources.For Alias, keep it as Off.For Routing Policy, choose Failover.For Failover Record Type, choose Primary.For Record ID, enter a name.For Associate with Health Check, choose Yes, and then choose the health check you created previously.Choose Create records.Create the failover endpointOpen the Amazon Route 53 console, and then choose Hosted zones.Choose the hosted zone that you want to create the record for.Choose Create record, and input the following:For Record name, use the same value that you entered for the primary record.For Record type, choose A – Routes traffic to an IPV4 address and some AWS resources.For Alias, choose Yes.Note: Aliases automatically use a time to live (TTL) that matches the alias target.Under Route traffic to, for Alias to S3 website endpoint, choose the S3 bucket that you created previously.For Routing Policy, choose Failover.For Failover Record Type, choose Secondary.For Record ID, enter a name.Note: The name for the Record ID on your failover endpoint must be different from the name of the Record ID on your primary endpoint.(Optional) For Health check ID, choose a health check.(Optional) For Evaluate target health, turn off the option. When the target is an S3 bucket, the option doesn't work. For more information, see Failover routing.Choose Create records.

Related informationChoosing between alias and non-alias resource recordsConfiguring DNS failoverMonitoring health check status and getting notifications