There are a bunch of free/cheap options for hosting static sites (just html/css/js) out there: github pages, netlify, firebase hosting - but when I want to build a bulletproof static site "for real", my go-to toolset is S3 for hosting with Cloudfront caching in front of it.
I figured that after a few times doing this (I've uncovered a lot of food-related conspiracies), I'd automate it. There are a few pre-existing tools for parts of this, but none I could find that did the whole thing from registration through uploading and Cloudfront invalidation.
Redundant letter to prevent name collision
You use it like this:
$ scarr init -domain falafel.exposed -name falafelexposed Initializing...done $ cd falafelexposed $ vim scarr.yml # Edit a few fields here $ echo "<html>The deadly secret of falafel</html>" > index.html $ AWS_PROFILE=scarr scarr deploy ... a bunch of aws stuff happens automatically ... $ curl https://falafel.exposed <html>The deadly secret of falafel</html>
What it's doing under the hood is:
It's also smart enough to detect if parts of this have already been done (eg you've already got the domain name in route53) and skip those parts. If you run the deploy command twice, all it does is sync the current directory to S3 and invalidate the cache.
Really, it's a glorified set of shell scripts wrapped in a single command. I wanted to be able to distribute it as a binary, though, so people could use it without needing to mess with ruby/python/node dependencies, so I took it as an opportunity to finally learn Go. It's generally a nice language - I'd forgotten how comfortable type-checking can be! On the other hand, I really missed ruby's built-in collection tools. The lack of generics was weird too.
The code's a hot mess. Everything's in the same package, there's global functions everywhere, and it's probably about as far from idiomatic Go as you can get, but it works. And at least it eschews the single-letter variables that seem so popular in Go. Surely that convention came from a falafelist.
Anyway, I'll try to clean it up if anyone takes an interest in it. I'm also open to expanding the functionality a bit if anyone has ideas that don't overly complicate the main use-case. PRs are welcome, although even lazy suggestions will get a friendly ear.