As of the time of this writing this site runs on several platforms and services:
- Google Domains
- Bitbucket & Bitbucket Pipelines
- AWS Cloudfront
- AWS S3
- AWS Route53
Here are the steps I took to set this up:
-
Purchased the domain from Google Domains.
-
Created an AWS Hosted Zone in Route53.
- Route53 will provide 4 Name Servers like these
-
In Google Domains I setup custom DNS servers to use the 4 Name Servers provided by Route53
-
Created AWS S3 bucket
- Very important: Do not enable Static Website Hosting
- This bucket has no public access
- Only access is from CloudFront OAC
- Created a Bitbucket repo for this site
- This includes a pipeline to the AWS S3 Bucket which automatically updates the S3 bucket
- Clone repo and add files for website
- Deployed CloudFront distribution
- Origin is S3 bucket created earlier
- Provisioned custom SSL Certificate
- Add CNAME entry in Route53
- Forward HTTP to HTTPS
- Create A record in Route53 to point to CloudFront distribution
Here is the flow of accessing my site from a user’s perspective: A user opens a browser to https://askben.cloud, Google domains sends them to Route53 for DNS processing. Route53 processes DNS queries and forwards the request to the CloudFront distribution which uses the S3 bucket for the files. Users do not have direct access to the S3 bucket. In some circumstances a developer may want S3 to have public access. Depending on your setup you may have to allow this. For my setup there is no public access.
In addition, developers (in other words me ;-) ) commit changes to the Bitbucket repository which has a pipeline that monitors changes to the repository. This pipeline makes sure that any changes are sync’d to the S3 bucket. From there CloudFront updates the global Content Delivery Network (CDN). The process from my laptop to S3 takes a few seconds. But updating CloudFront might take a day or so unless I invalidate the distribution. An invalidation request will clear out the CDN and cause an immediate distribution of the new S3 contents to the CDN.
The Basics
This is what makes it blazingly fast and makes it so awesome.
AWS Cloudfront
Edge Locations, a global network of data centers, is how CloudFront distributes content. By delivering content closer to viewers, edge servers that cache and provide content enhance performance. A nearby Edge Location receives a user’s request for content that you serve over CloudFront. If CloudFront has a cached copy of the requested file, it sends it to the user and responds quickly (with low latency). CloudFront retrieves the requested file from your origin, such as the S3 bucket where you’ve kept your content, if it hasn’t already been cached. When the same content is then requested again locally, it is already cached nearby and can be provided right away.
Amazon S3
An object storage service called Amazon S3 provides performance, security, and data availability that are unmatched in the market. Amazon S3 is designed for 99.999999999% (11 9’s) of durability and stores data for millions of customers worldwide. It can be used to store and protect any amount of data for a variety of use cases, including data lakes, websites, cloud-native applications, backups, archives, machine learning, and analytics.
Bitbucket Repository
In GIT, repositories are collections of files from several Project versions. These files are imported from the repository into the user’s local computer for additional updates and content changes. These versions are made using a VCS, or version control system, and are kept in a repository, which is a specified location. Cloning is the process of using different Git Tools to transfer the content from an existing Git Repository. The user receives the entire repository on his own computer after the cloning operation is finished. Once the cloning is complete, Git by default expects that the work to be done on the repository will be done as a user.
Route53
Use Amazon CloudFront to distribute content from your website’s root domain, or “zone apex.” As an illustration, you may now set up https://www.askben.cloud and https://askben.cloud to point at the same CloudFront distribution without suffering from a performance hit or running the risk of an unavailable site. To make use of this capability, you need to link the domain’s root to your CloudFront distribution using an Amazon Route 53 Alias record.