How to failover a website to a static website on Amazon S3 using Route53

Suman Parua
4 min readMar 27, 2022

In this article, I would touch upon how to failover a website to a static website on S3 using Amazon Route53. This mechanism would be particularly useful for website maintenance operations where users will be served with the maintenance page from the static website setup from the S3 bucket

Before we start, I would briefly explain the AWS services to be used for this as well as the conceptual architecture of the website that we are going to failover

AWS Services Used

  1. Amazon EC2 — The most popular compute service of AWS, we would assume the website is made up of a series of EC2 instances ( Virtual servers) set up in an auto-scaling group behind an application load balancer and running in 3 availability zones in us-east-1
  2. Route53 — Amazon Route 53 is a highly available and scalable cloud Domain Name System (DNS) web service. It is designed to give developers and businesses an extremely reliable and cost-effective way to route end users to Internet applications by translating names like www.example.com into numeric IP addresses like 192.0.2.1
  3. Amazon S3 — Stands for Simple Storage Service and provides unlimited object storage in the cloud which is built to retrieve and store any amount of data from anywhere. The data stored in S3 is highly durable and highly available ( based on use cases)

The conceptual architecture of the application is as follows

Conceptual application architecture

Let’s assume our website uses the URL — blog.mytechwebsite.com

Setup the website:

STEP1: In order to set up this website, we will first create the hosted zone for mytechwebsite.com

STEP 2: Setup the EC2 instances running behind the ALB using an autoscaling group. Let’s assume the DNS name for the ALB created is http://MyTestLoadBalancer-174984295.us-east-1.elb.amazonaws.com

STEP 3: Setup a Route53 health check for checking the health of the ALB. Make sure the security group of the ALB allows HTTP traffic on Port 80 from anywhere for the health check to work

Allow ALB security group HTTP access on port 80 from all IP’s
Setup the ALB Health check

STEP 4: Setup the Route53 DNS records for the website using failover routing, set up the Primary record only now. Notice the selection of Failover as Routing policy and the ALB-Healthcheck selected to evaluate the health of the ALB for failover.

Setup failover routing

STEP 5: Create an S3 bucket with the exact same name as the website, ie the bucket name should be blog.mytechwebsite.com

Create bucket with exact same name

Update the bucket policy to make it public and import the application maintenance page into the bucket, say index.html

STEP 6: Setup an S3 static website against this bucket. The home page of the website will contain the website maintenance page ( index.html) to be displayed in case of a failover.

Sample message in index.html file

STEP 7: Now we have to set up the Secondary DNS entry for the failover in Route53. This step is the most important.

In the DNS entry, the name of the s3 website to route traffic to should be s3-website-us-east-1.amazonaws.com

Do not select health check as S3 is highly available and is not required in this case.

Secondary failover record for routing to S3 website

Now we are fully set up to failover to the static website. We can trigger this failover by somehow making the ALB health check return an unhealthy status.

Both Failover primary and secondary entries for the website

STEP 8: To make the ALB health check return an unhealthy status we can just remove the HTTP port 80 access from the ALB security group. Remember we setup the ALB healthcheck in STEP 3 on Port 80. Once the ALB health check becomes unhealthy and depending on the TTL value of the DNS record very soon the requests to blog.mytechwebsite.com will be routed to the static website on S3.

if we remove the entry for HTTP on Port 80, Route53 will think the ALB is unhealthy

Now users accessing the URL “blog.mytechwebsite.com” will be redirected to the S3 static website by Route53

Sample message in index.html file

--

--