This weekend I got curious. How lightweight could an Amazon S3 download script be?
There are plenty of AWS and S3 command line tools and libraries for everyone’s favorite scripting languages, but as I’m currently working in the IoT space, I wondered what the smallest number of dependencies was that I could get away with and still authenticate a private file download.
Here is what I came up with:
As you can see, looking at the code, it’s a really simple Bash script. The main dependencies are curl and openssl. As it turns out, the signature is a very simple HMAC-SHA1, so openssl can easily do it on the command line.
More than a little bit of inspiration came from this article about uploading to S3 in Bash. Clever stuff!
A vague source of mild frustration (as usual) was making a script that works on Linux and Mac OS X. As usual, since the date program is crippled on OS X, cross-platform relative date calculations are a bit… tetchy.
Anyway, s3dl is released under cc0 / Public Domain, so you may feel free to do with it what you will. Enjoy!