Updating Lambda Functions for this Blog

This blog has a neat surprisingly monolothic install procedure. I like that it works when it works. It's not good at updating specific items though and I find myself updating some Lambda functions several times a day. One reason is to try to use Node.js 6.10 instead of the original 4.3 environment. Or reducing memory to 256MB instead of 512MB. Or adding webpack with tree-shaking (AKA dead-code elimination) to make those Lambda functions not 40k lines long (but 'only' 2k lines).

Anyway, doing this by deleting everything and re-installing everything is fine until the day there are blog entries and re-installing might unexpectedly wipe our your blag articles. Thus I'd rather be able to refresh the Lambda functions knowing that nothing else will be modified.

So here the simple steps for a more granular update procedure, mainly for for Lambda functions:

List them all

aws --region us-east-1 lambda list-functions \
| jq -r '.Functions[] | select( .FunctionName | startswith("blog_")) | .FunctionName'

Delete them all

aws --region us-east-1 lambda list-functions \
| jq -r '.Functions[] | select( .FunctionName | startswith("blog_")) | .FunctionName' \
| xargs -n 1 --replace={} aws --region us-east-1 lambda delete-function --function-name={}

Redeploy them all

Actually deploy what's missing.

node upload_lambda.js

A good way would be to have two different releases which would make a roll-back very simple too.