◄︎ Gregor's Portfolio Site
15 May 2019

Hosting a static site on aws

For over a decade I've bounced between GoDaddy and NameCheap for all my personal domain and web hosting needs. While those services are easy, they don't provide the scaling or performance to match my current 2019 use cases. As a result I've shifted to Amazon Web Services.

On AWS a basic static website can be created using two services: Route 53 and S3. And If we want a secure website we can enable https by including CloudFront into our configuration.

Pros and Cons of S3 Website Hosting

Low Cost. Cloud pricing can get extremely complex, but it ultimately is very low cost. On S3, each Gigabyte of storage costs approximately $0.023 cents per month.

Speed. Without getting into the nitty gritty of Regions and CDNs, for all intents and purposes serving files from S3 will be limited only by the user's network speed.

The major drawback of using S3 is it can only be used to host static websites and client side scripting. This means it can be used to host a React.js site, or Vue.js. But it cannot be used for Wordpress or any PHP or node.js code.

Basic setup HTTP setup


If you're looking to make your website available at a custom domain name you'll have to purchase it first. That can be done through AWS or with any other domain registrar. However if it is purchased outside of AWS you'd need to point the NS records to a Route 53 hosted zone so your domain can be managed on AWS and used in the configuration below.

S3 Setup

Route 53 Setup

Now that we have an S3 bucket accessible by an Endpoint URL we need to make it accessible through our domain name, too.

Certificate Manager Setup

Before we enter into CloudFront we want to create a new SSL certificate.

CloudFront Setup

Route 53 Updates

We're almost done. Our CloudFront distribution contains a valid SSL certificate and we need only to map the URL to the one of our choosing. We'll do that by removing our old S3 HTTP endpoint alias and replacing it with the HTTPS endpoint generated by CloudFront.

Further reading: