Too Complicated: Alternatives to S3 for Static Web Hosting10 Jun 2020
I was planning to write a blog about how easy and cheap it is to use S3 for static web hosting. About how I set this blog up on S3 in a short afternoon, and how you can do the same thing for your website. That was the plan.
And I did set this blog up on S3, but it took longer than I thought it would. Rather than a short afternoon, it was a long afternoon and well into the evening. And at the end of the day, although things were kind of working, they weren’t working as well as I wanted them to. Nothing was as simple as I wanted it to be. So I decided to ditch S3! I moved to a different web host and got the whole thing set up – again – in under an hour. Like I wanted to do the first time!
AWS S3 is a really great solution for certain use cases. It meets the online file storage needs of a lot of different enterprise-scale systems. But if you’re planning to use it to set up a simple static website (HTML, CSS, and a little JS) quickly and cheaply, it might not be the best thing to use. Let me explain.
Initially, it seems simple and appealing to host some static content on S3. AWS
is trusted by huge companies, and their pricing is good. You expect to simply
create a new bucket, set up an access policy with public read permission, then
configure the bucket to serve a static site (configuring
possibly an error page). At that point, you really do have a static web hosting
solution that was cheap and relatively easy to set up (though you still had to
deal with bucket access policies and other advanced config options you don’t
need). But that’s all you have. A public S3 bucket accessible from the web.
Importantly, you don’t have a custom domain or HTTPS.
It’s possible to set up a custom domain and HTTPS with AWS S3, but that’s significantly harder than just hosting a static website on S3. To set up a custom domain name with HTTPS, you’ll have to use Route53 for the domain, Amazon Certificate Manager for HTTPS, and you’ll have to use CloudFront (because you can’t use https with a custom domain on a normal S3 static website endpoint). CloudFront comes with big benefits (namely, making your site a little faster with a CDN), but also big costs (because it’s a CDN, you now have to deal with cache invalidation). For a simple static website that’s more of a weekend project than a large commercial enterprise, all of this is overkill.
And there are better alternatives out there! Here are some to consider.
- NearlyFreeSpeech offers very low-cost static web hosting where you only pay for what you use. They’re particularly good for low-traffic sites like experiments and profiles.
- This site (at the time of writing) is hosted on Netlify. They have a free tier, and setup was a breeze.
- If your project is open-source, just use GitHub Pages.
- Other shared hosting providers like DreamHost or HostGator are also easier to set up than AWS S3.
There are trade-offs to pretty much every decision in web development, and there’s never a one-size-fits-all solution. For me, on a small site or blog, it’s most important to have something simple with low complexity, so a simple hosting solution is better than a relatively complex S3 setup (with Route53 and CloudFront).