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

4 minute read
0

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 description

Before 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.

Resolution

Configure 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:

Create the Route 53 health check

  1. Open the Amazon Route 53 console, and then choose Health checks.
  2. 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.
  3. Choose Next.
  4. For Create alarm, choose Yes.
  5. Choose Create health check.

Note: For more information, see Creating and updating health checks.

Create a record set for your primary endpoint

  1. Open the Amazon Route 53 console, and then choose Hosted zones.
  2. For Domain Name, choose the domain of the hosted zone that you want to create the record for.
  3. 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.
  4. Choose Create records.

Create the failover endpoint

  1. Open the Amazon Route 53 console, and then choose Hosted zones.
  2. Choose the hosted zone that you want to create the record for.
  3. 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.
  4. Choose Create records.

Related information

Choosing between alias and non-alias resource records

Configuring DNS failover

Monitoring health check status and getting notifications

AWS OFFICIAL
AWS OFFICIALUpdated a year ago
5 Comments

I applied for the domain name Godaddy, which is bound to the DNS of AWS Global Accelerator, apache2 is configured with ssl, and my domain name is added to Route 53. The regional hosting settings failover to S3. Why is there an error 502 Bad Gateway? Is it bound to the DNS of AWS Global Accelerator? The reason is still the reason for the SSL configuration. How should I set it up to fail over to the S3 static website? AWS Global Accelerator connects to ALBs in different regions for cross-regional load balancing

replied a year ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied a year ago

After using CloudFront to serve HTTPS requests to my Amazon S3 bucket, should I still configure routing traffic to S3?

replied a year ago

When editing a Route53 record, the console does not have an Associate with Health Check. There is a Health check ID drop down list to select a Health check from.

replied 6 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 6 months ago