Deploy a Static Website using AWS S3 and CloudFront

Nikola Kuzmic
Geek Culture
Published in
10 min readMar 29, 2022

--

Simple walkthrough on how to add AWS CloudFront CDN to a Static Website hosted on S3 and connect it to your personal Domain via Route53

If you are here, you probably know that CloudFront enables you to serve your website much more efficiently to people around the world by leveraging caching on edge nodes and enabling HTTPS for website visitors. Hence, we’ll dive right in and show you how you can deploy a simple Static Website on S3, connect it to your own Domain (example.com — purchased on GoDaddy) and finally add the awesome CloudFront to it. Please note that I’ll be using Vue, but the process is the same for React as well as other frameworks.

The diagram above can be somewhat confusing because it presents the final state and only what service points to what. The process to construct this is somewhat backwards.

We first start by creating and packaging our App, then hosting it on S3. Afterwards we create a Route53 Hosted Zone which routes traffic from our domain to the S3, and finally add CloudFront in between Route53 and S3. Although this might sound confusing, it’s actually pretty simple.

👉 Game Plan

  1. Create and package your App (Skip this section if you have your own)
  2. Host the App on S3
  3. Connect the S3 Website to the Custom Domain Name using Route53
  4. Add CloudFront

👉 1. Create and package your App

To build a boilerplate Vue project you need to have Node.js/npm and Vue Cli installed. Check that you have them (Mac commands)

$ node -v
v14.18.0
$ npm -v
6.14.15
$ vue --version
@vue/cli 4.5.15

Then simply in terminal we can make a directory for the project & run

mkdir vue-cdnvue create .'Type Y'Press Enter to create a 'Default Vue 2 Project'

Let’s open the newly created project

--

--

Nikola Kuzmic
Geek Culture

Making AWS super simple. Follow for practical Data & ML engineering guides. https://www.linkedin.com/in/nikolakuzmic/