Hosting Static Website with AWS

Last Updated: November 17, 2021

In this read through you will learn a little more about the AWS services I used in hosting a static website on Amazon Simple Storage Service (S3). However before jumping into an S3 summary, let's look at why we use AWS instead of other cloud providers:

  • They have the "Free Tier" which is a huge benefit for anyone trying to learn AWS or Cloud in general, combined with the already low costs.
  • Their services offer unmatched scale, elasticity, performance, and security.
  • It is one of the easier to learn for practical examples.

In this post I will be providing a exaplnation for why I did the following:

  • Host your website using Amazon S3
  • Using AWS CloudFront as a Distribution service
  • Making your website secure (SSL certification) using Amazon Certification manager
  • Buying and configure my domain using Route 53

Why Host your website using Amazon S3

The number of websites on the internet are incresingly becoming static websites which means they run absoultely no server side code and consist of only HTML, CSS, and JavaScript. With no server side code to run, there is no reason to host them on a traditional server like EC2. This is where AWS S3 comes in. By using the static website hosting feature on an S3 bucket, we host static websites for one to two dollars a month and scale to handle millions of users.

Low Cost - Hosting a website in S3 does not incur entra charges. You are paying standard S3 prices on GET requests and Data Tranfer out of the bucket when a user visits your site.
     GET Requests cost $0.004 per 10,000 requests
     Data Transfer Out cost $0.090 per GB (up to 10 TB / month)

Lets say your website loads 20 resources. The total size of those resources per visit is 1MB. The average total monthly visits is 20,000. Then we estimate the total cost of S3 on a monthly basis at around $1.96 per month.

Maintenance - Your static website now resides in S3. There is no longer any server side code to maintain and no web servers to configure and keep up to date.

Scale - S3 is a high availability and durable service that AWS maintains. If your website goes from 10 users a day to 10 million, S3 scales your website automatically.

Security - There is no server running that you maintain. Thus you avoid making configuration errors that make you vulnerable to attacks.. You are still responsible for the security of your bucket. Remember your website bucket is public!

Those are some serious win under your belt. With an S3 website setup, you have a foundation to build on to extende and leverage even more of AWS.

Why Use AWS CloudFront as a Distribution Service

Amazon CloudFront is a Content Delivery Network (CDN) offered by AWS to deliver data, videos, applications, and >>>>> Websites <<<< hosted in Amazon S3 buckets. It is and easy and cost-eefective way to distribute content worldwide with high data tranfer speeds and low latency. A CDN is a geographically distributed group of servers and their data centers with aim to provide speedy delivery of content. CDNs let users connect to data centers which are geographically closer to them, meaning lesser the distance faster the service.

CloudFront copies all pages of websites to a network of servers that are deployed globally at different locations (Edge Locations), caching the content of the page. When a user requests a webpage, the CloudFront service redirects the request from the originating sites server to the server in the CloudFront network that is closest to the user and delivers the cached content. For files that were not cached at edge locations, CloudFront keeps communicating to your origin servers so that those files can be fetched from origin servers as quickly as possible.

CloudFront aditionally seamlessly intergrated with AWS WAF, AWS Shield, AWS S3, and ACM (AWS Certificate Manager). ACM is used to produce several custom SSL certificates as needed and depoys them to your CloudFront distributions at no further costs. This is how our design is configured. The S3 bucket hosts our website pages, Cloudfront distributes it worldwide, and ACM provides and deploys our certificate so our site can use HTTPS protocol for secure website communication. We will talk a little more about ACM in the next section.


Making my website secure (SSL certification) using Amazon Certification Manager

Every once in a while you will find a website with one of the following certificate warning messages, which is linked to the SSL/TLS Certificate used on the site. Some of the causes for this include - Use of an untrusted certificate or revoked existing ccertificates due to malicious activity etc. These are easily solved problems but cost a user or organization trust and some times a potential site release. Fourtunately ACM easily resolves this problem

Amazon Certification Manager (ACM) is an AWS service that allows users to produce and deploy SSl Certifcates, but the real benefit is the fact that ACM is an AWS managed service. So ACM mechanically handles certificate renewal, eliminating the overhead prices of a manual renewal method.

Buying and Configuring my domain using Route 53

Amazon Route 53 is a highly available and scalable Domain Name System (DNS) web service. You can use Route 53 to perform three main functions in any combination: domain registration, DNS routing, and health checking.

The combination of Amazon CloudFront and Route53 lets you use a custom domain name for your serverless website taking advantage of the benefits listed above.