so

Lambda me this

Volume 7, Issue 45; 17 Nov 2023

Normal service has been restored. My AWS lambda works again.

I prefer to host things myself. Self-hosting is fiddly and annoying, and it requires specialized knowledge, but by about the second or third time I got burned because a service made arbitrary changes to their terms, raised the rent, or got sold off, I decided that for blog posts and photographs, at least, I was done. I have the specialized knowledge required and I’m stubborn.

For blog posts, self-hosting works pretty well. My setup is a bit…well, fiddly, but it works. I can easily write posts in Emacs and publish them. In a pinch, I can write posts in the browser (on a mobile device, for example) and post them. Good enough.

For photographs, it’s harder. A while back, I automated a workflow to publish photographs from my phone. Then I stopped thinking about it. And now, four(ish) years later, AWS is dropping support for the version of Python I used (3.7). Not unreasonable, but I haven’t thought about that lambda in four years. You know what you discover if you ignore some bit of AWS for four years? You discover that it’s all different now.

Zbigniew Pieślak has an an excellent post about getting exiftool working in a lambda. That part is the real heavy lifting. I struggled a little bit with making the layer because my Mac wanted to build ARM binaries not x86 binaries. I don’t know how easily solvable that is: I punted and built the layer on my old x86 Mac.

Then there was the question of how to install additional Python libraries. The trick, a couple of hours in the finding, is that you have to make sure they’re installed in python/lib/python3.11/site-packages/ in the layer. Also, install all of the modules you need, even things like boto3 that you’d expect to be installed by default. (I had a really weird problem that manifested as a bizarre SSL error before I installed my own version of boto3.)

That was followed by the expected fiddling with permissions and setting up triggers. The instructions in the exiftool post make a stack, so it’s easy enough to start over. If I was being diligent, and if I wasn’t retrofitting a few bits of the existing system, I’d work out how to do everything using a stack, including how to configure the permissions for the “drop box” bucket. That would be better. But I’m not. (Note to my future self, “sorry, man, other things to do.”)

The Python image libraries are better now, they handle the HEIC format that Apple uses. That turns out not to matter much, though, because I add metadata to the images and that process turns them into JPEG images anyway. I’ve also fixed a few small bugs that have inconvenienced me over the years: images without the expected date/time metadata for example.

I had a good few minutes of cursing at the author of exiftool when I discovered arbitrary changes have been made to the namespace URIs in the XML output. (They used to be HTTP URIs on the exiftool.ca domain, now they’re on exiftool.org.) Don’t. Do. That.

But, all in all, it seems solid and as a random bonus even handles animated GIFs correctly.

#Lambda #Photography