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