Skip to content

Instantly share code, notes, and snippets.

View instantiator's full-sized avatar
🐠

Lewis Westbury instantiator

🐠
View GitHub Profile
@instantiator
instantiator / 0. Deleting lambda versions.md
Created January 22, 2026 11:03
A script to remove all but the latest version of all lambda functions found in a stack.

Deleting old lambda versions

Tip

Serverless Land offers a Lambda function cleanup step-function pattern, which can also help you to manage steady accumulation of lambda versions.

This script fills a similar niche. It will review a CloudFormation stack and remove all but the most recent N versions of all versioned lambda functions it finds there.

Context

If you have enabled Lambda versioning for your AWS deployment (perhaps because you want to be able to use Lambda SnapStart to reduce some inconveniently long cold-start times for certain runtimes, or maybe because you want to control version updates), you may be surprised to discover that all your lambda versions are preserved ad

@instantiator
instantiator / view-function-log.sh
Created January 13, 2026 16:45
A short script to retrieve logs from a specified Lambda function in a specified CloudFormation stack.
#!/bin/bash
# A script to view logs for a specific Lambda function in a CloudFormation stack.
set -e
set -o pipefail
function usage() {
echo "View logs for a specific Lambda function in a CloudFormation stack."
echo "Usage: $0 -s <stack-name> -f <function-name> [-r <region>] [<other-aws-logs-args>]"
@instantiator
instantiator / empty-bucket.sh
Last active February 21, 2025 13:02
A script to completely empty a versioned S3 bucket, in preparation for deletion. Run with `--help` to see the help information. Core details from this excellent StackOverflow advice: https://stackoverflow.com/a/61123579
#!/bin/bash
set -e
set -o pipefail
usage() {
cat << EOF
Dangerous script. This script will empty a specified bucket.
Options:
@instantiator
instantiator / responsive-embed-google-slides.html
Created November 4, 2023 15:59
Responsive embed for a published Google Slides presentation.
<!-- Responsive embed for a published Google Slides presentation, scales with width and preserves proportions. -->
<!-- Standard google slide dimensions are: 960 x 569. Height is roughly 60% of the width. -->
<div style="position: relative; width: 100%; height: 0; padding-bottom: 60%;">
<iframe frameborder="0"
style="width: 100%; height: 100%; position: absolute; left: 0"
allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"
src="https://docs.google.com/presentation/d/e/2PACX-1vQ6WWyyAQK2A0zYRuIGV08vqbZNXCCNvZ7h2FKTWlEbGmWwpb4VgB6j33RiXuWx9NCOr5xJVq7FmFCb/embed?start=false&loop=false&delayms=3000">
</iframe>
</div>
@instantiator
instantiator / cloud-formation-vpc-with-internet.md
Last active April 26, 2024 15:50
AWS CloudFormation/SAM templates for an app that places lambdas inside a VPC, and restores their internet access

Sometimes you need to move your application lambdas inside VPC subnets (eg. if you need them to be able to access an RDS cluster, or another service that doesn't mesh perfectly with serverless). Doing so removes them from the default VPC, and with that they lose internet access.

The templates included here show how you can deploy lambdas inside a VPC, and create a route for them back to the internet.

You can still use API Gateway and trigger your lambdas with events, but now they'll be able to reach the internet, too.

template.yaml creates the VPC, which is then used by all the other resources.

@instantiator
instantiator / build-fap.yml
Last active July 30, 2023 08:50
GitHub Action to build FlipperZero app with ufbt
# place in .github/workflows
name: "build with ufbt"
on:
push:
branches:
- main
pull_request:
branches:
- '**'
jobs:
@instantiator
instantiator / duplicate-dynamodb-table.sh
Last active July 14, 2023 15:44
Bash script to copy one AWS DynamoDB table to another
#!/bin/bash
# exit on error
set -e
set -o pipefail
usage() {
cat << EOF
duplicate-table.sh <first-table-name> <second-table-name>
EOF
@instantiator
instantiator / PathProxy.js
Last active July 14, 2023 15:28
An experimental javascript Proxy object that reports the path that was requested (some limitations)
/** An experimental Proxy that reports the path that was requested */
class PathProxy {
constructor(id) {
let proxy = new Proxy({ identity: id }, {
get: (target, name) => {
if (name.toString() === 'identity') {
return target.identity;
} else {
if (!(name in target)) {
target[name] = new PathProxy(`${target.identity}.${name.toString()}`);
@instantiator
instantiator / png-to-svg.sh
Created July 22, 2022 15:17
Bash script to trace png to svg, using imagemagick and potrace
#!/bin/bash
function print_params() {
echo "Usage: png-to-svg.sh <path-to-png>"
echo
}
# OS X - install pre-requisites
if [ ! -x "$(command -v magick)" ]; then
brew install imagemagick
@instantiator
instantiator / summarise-entity-ids.sh
Created January 5, 2021 17:04
summarise the entity ids found in yaml configuration files
#!/bin/bash
# provide the path to your configuration yaml files as the only parameter
DIR=$1
echo \"file\",\"simple id\",\"LOAs\",\"entity id\",\"MSA entity id\"
for FILE in "$DIR"/*.yml; do
FILENAME=$(basename $FILE)
SIMPLE_ID=$(yq eval '.simpleId' $FILE)
LOAs=$(yq eval '.levelsOfAssurance' $FILE)