amazon-web-servicessslamazon-s3httpsamazon-route53

Cheapest way to host a SPA or static website with https on S3


Problem

I want to host multiple websites, each with ssl(https) and to not have to spend more than I have to.

I would also like to keep using Route53 if possible(but not necessary) because I understand how to use it and it's only costing me about $0.50/month.

Background

My backend/server understanding is very limited.

I've created some react websites(I think I'm using the word static correctly, there's some stuff that javascript changes) and currently I'm hosting each on an ec2. I used certbot(lets-encrypt) to enable https for my websites. The domain names are handled through Route53 and Namecheap.

S3 & Cloudfront

I want to put my sites on S3's to save costs. I need https though. Most tutorials that I look at talk about using cloudfront. It looks like cloudfront is going to cost me something similar to what my ec2's are costing me anyway, so it doesn't look like a solution to me. Maybe I'm wrong? Will the costs be insignificant?

Route53 & NGINX

It looks like I might be able to do this with Route53? Theres an answer from Gianluca Casati, but he didn't really provide enough detail for me to work with.

Some other tutorials explain it, but talk about setting up an NGINX server, and I don't really know what that is. I'd like to avoid NGINX if possible but I'll use it if I have to.

This is starting to get very complicated so I wanted to know if there is an easier way. If not what are all the steps involved


side note(if you can answer this also, it would be helpful, but isn't necessary)

I would also like good SEO. For at least one of the websites, it looks like this will involve dynamic rendering, using rendertron or puppeteer or something. Not all of my websites need this, but one will. It would be nice to know if this is possible or not.


Summary:


Solution

  • I'll try to provide answers to your questions in order.

    Cloudfront: will the cost be insignificant?

    Yes, incredibly so. Below is a screenshot of a random bill from my AWS account:

    enter image description here

    Here is the Cloudfront pricing breakdown presented on a typical AWS invoice:

    enter image description here

    Route53: can I do this with Route53?

    Yes it will be necessary. NGINX is not necessary.

    The 4 AWS services you will need are:

    This is an excellent guide for the basic procedure:

    https://medium.com/@sbuckpesch/setup-aws-s3-static-website-hosting-using-ssl-acm-34d41d32e394

    You can skip the parts about SES for the basic setup, but if you ever need to setup a form that submits to your email inbox, then you might want to look into it.

    In short, the answer is yes. You can use S3 and Cloudfront to accomplish your goal without a bunch of backend-server knowledge and for pennies per month. The method and services described above is exactly how you do it.