AWS Hybrid Cloud Testing – Part 2 – Distribute static website over Cloudfront

This is part II of the AWS Hybrid Cloud testing series. In this post, I will be discussing how to test static website when it is being distributed and delivered over CloudFront.

A significant number of websites have static content. So instead of hosting them on a web server, it makes sense to host them on s3 bucket in AWS, thereby reducing the cost of running the static website.

In addition, CloudFront allows the static content to be distributed all over the globe through its Edge servers thereby reducing the time it takes users to retrieve and view the content as it is easily scalable.

The infrastructure is setup as below:

  • Create a static website with an html page and an image added to the html webpage (for demo purpose)
  • Create an s3 bucket with the same name as the static website domain name
  • Now go to s3>Properties and select Static website hosting, properly configure the settings with index document and error document
  • Now copy the html page and image to  the s3 bucket, the static website should be available over the domain name
  • Create a CloudFront distribution and set it up with the s3 bucket origin name
  • Once the CloudFront is created, it will be accessible over its domain name

Here are the screenshots of what the website looks like when accessed over s3 and over CloudFront.

Static website accessed over s3 bucket:

Static website accessed over CloudFront distribution:

The domain name of CloudFront instance is as below:

Cloudfront1

 

Cloudfront2

The type of testing that you would want to do here are:

  • When static website is configured to be delivered over CloudFront, try to access objects in the s3 bucket, this should not be allowed
  • Use VPN to change your location and then access the website, there should be no discernible difference due to use of Edge server, no matter where your traffic originates
  • The objects in s3 bucket should be encrypted if encryption is enabled
  • Add new content to the static website in s3 bucket and this should be immediately available across the globe over CloudFront

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.