DEV Community

Bhuvaneswari Subramani for AWS Heroes

Posted on • Updated on

Enabling resiliency for a static website hosted on AWS Cloud

"Everything fails all the time." says Werner Vogels, CTO & VP, Amazon.
Though, happily hosted my personal website on Amazon S3 as a static website hosting in the Mumbai region and set up CI / CD to integrate the changes from GitHub repo to Amazon S3.
Is the disaster recovery in-place or is it resilient?

What is Resiliency?

Resiliency is the ability for a system to recover from a failure induced by load, attacks, and failures.

Amazon S3 is highly available and resilient for zonal failure but is the website resilient for a regional disaster like power, weather.,? Though the chances are very remote with AWS Cloud, let's make the website resilient by setting up disaster recovery. Of course, the cloud has better ways to help provide business continuity, and here is one.

Table of Contents

AWS Services Used

  • S3
  • Route 53
  • CloudFront
  • IAM

Best Practise

  • Ensure to tag all the resources that you create.
    • S3 dr bucket
  • I have created two tags (Name: Bhuvana.pro and Usage: website), which will help for resource grouping and cost analysis.
  • To standardize example.com, www.example.com, and dr.example.com is used as root and subdomain throughout this article

Design

Alt Text

Detailed Implementation Instructions

Create S3 bucket for Disaster Recovery

  • Create an S3 bucket (say dr.example.com) in a different region to set up a disaster recovery site for the website example.com and configure for static website hosting as follows

Alt Text

Important Note Ensure versioning is enabled for both source (example.com) and destination bucket (dr.example.com)

Setup replication from example.com to dr.example.com

Select the main S3 bucket, example.com, and go to the Management tab, select Replication rules and click Create replication rule

Alt Text

Alt Text

Alt Text

Alt Text

Alt Text

Alt Text

Alt Text

Create Origin Group

Our ultimate goal is to remove the single point of failure, implementing automatic detection of failure, and configure a redundant path to establish business continuity.

Now that you have the dr-s3 bucket created and replication configured source, let's proceed to add Origin Group to your Cloudfront distribution pointing to your static website.

Edit the Web distribution created for your static website and add another origin pointing to the disaster recovery S3 bucket (dr.example.com) and here is the setting for the new origin.

Alt Text

The next step is to create an Origin Group with both the origins as follows with S3-example.com as primary and S3-dr.example.com as secondary.

Alt Text

Time to test for resiliency!!
Go and delete the S3 bucket (example.com) where your static website is hosted and watch the Cloudfront re-directing the request to the disaster recovery S3 bucket (dr.example.com).

Top comments (1)

Collapse
 
waswani profile image
waswani

Do we need static website hosting configuration as we are configuring CloudFront OAI to access S3? Moreover, the endpoint configured in the CloudFront Origin is not the http endpoint of the S3 website but S3 bucket directly which is accessed over https?