In my last post, I talked about how I moved my DNS services from AWS Route 53 to Google Domains DNS. However, leaving Route 53 meant I had to reconsider how I would host my static websites. These sites had been hosted on AWS S3/Cloudfront, which (for best results) required Route 53 for zone hosting. So leaving Route 53 meant leaving S3/Cloudfront as my static website host. After considering several options, I decided to move my sites to Netlify.
In fact, I had been wanting to divorce myself from AWS, after relying on them for several years. I will discuss more on this in a future post. As far as hosting static websites, Netlify ended up exceeding my expectations and I found it far superior to AWS hosting.
Benefits of AWS
So the main benefit AWS S3/Cloudfront has over Netlify is the ability to host your site from your root domain (non www-prefixed). Netlify offers this capability if you use their DNS services, but I wanted to keep my DNS with Google (again, see my previous post on my DNS journey). I opted to change my sites to use the www-prefix so that I could use Netlify while keeping my hosted zones at Google.
Benefits of Netlify
There are many benefits that Netlify has over AWS…
Netlify’s CDN is Automatic
To use Cloudfront (AWS’s CDN service), you have to first setup an S3 bucket for static web hosting. You then have to setup a Cloudfront distribution pointing to your S3 bucket. And then you have to setup your Route 53 DNS settings to point to your Cloudfront distribution.
All of these steps have some minor complexities. Your S3 bucket needs a security policy, your Cloudfront distribution has several options to set correctly. And on top of all that, if you want www to root domain redirecting (or vice versa), you need to set up two S3 buckets and two Cloudfront distributions.
With Netlify, you set up your site, point your CNAME and A records in your DNS settings according to their instructions, and voila! You are automatically using their CDN (equivalent to Cloudfront). Your root domain will redirect to your www-prefixed domain automatically. In this regard, Netlify is way easier than AWS.
Netlify’s SSL Certificate is one-click
AWS is actually pretty awesome in that you get free SSL certificates for your AWS resources. But setting them up takes time. First, you need to provision a certificate. Then you need to verify your domain over email. Then you have to set up your Cloudfront settings to use the certificate.
On top of all that, you may need to change AWS region settings between wherever you are on and the N. Virginia region, which is the only way to provision and use your certificate.
On Netlify, you can provision your SSL certificate (free from LetsEncrypt) with one click, wait about 1 minute, and your site will be accessible via https. One more click, and you can force browsers to use https. Way easier than AWS!
Netlify Invalidates the CDN Automatically
With AWS, I used to have to invalidate the Cloudfront distribution from the command line everytime I pushed to S3. Otherwise I would have to wait a day or so to see my changes live. Of course, this was easy enough, since I incorporated it into a bash script every time I pushed to S3. But it is so nice that Netlify does this automatically.
Netlify is Free!
With AWS, my bill per domain would come out to about $0.70. $0.50 for a Route 53 hosted zone, and the remaining $0.20 split between S3 and Cloudfront storage and data transfer costs.
Granted it is not much, but free is still better. And without S3/Cloudfront, I am free to leave Route 53 and use the free DNS service at Google Domains.
Netlify has many more Features
One of the major benefits of Netlify is that instead of pushing your actual website when you publish, you can push the underlying files for a static site generator (like Jekyll or Hugo) and let Netlify build it. You would push the files to a Github repository and Netlify would build it automatically.
I actually tried it and it worked beautifully, but in the end, I decided to keep it simple. I build my website locally (using Hugo) and push the generated website to Github, which then gets pulled in by Netlify.
The main reason I decided against letting Netlify build my site is that the latest Hugo version has a bug that I have to fix with a bash script, so I need to do some processing locally. I actually already made a pull request with Hugo to fix this error, but it has not been incorporated into the latest build yet. But in any case, I still like the control that I have on my local machine.
But it is nice that Netlify has so many great options for building static websites. Netlify also lets you preview and rollback changes. As I start using Netlify more, I expect to enjoy all these features more and more. I am so impressed that Netlify offers such a full featured service for free. Definitely give it a try if you haven’t already!