Lambda layers for shell runtime tools and utilities
Pre-built Lambda layers containing common CLI tools and utilities for use with lambda-shell-runtime. Each layer provides statically-linked binaries optimized for AWS Lambda.
- jq - Command-line JSON processor
- qrencode - QR code generation from command line
- htmlq - HTML parsing and extraction tool
- yq - YAML/XML/JSON processing tool
- http-cli - Minimal HTTP client for shell scripts
- pcre2grep - Perl-compatible regex pattern matching
- uuid - UUID generation utility
# serverless.yml
provider:
layers:
- arn:aws:lambda:us-east-1:ACCOUNT:layer:ql4b-shell-qrencode:1
- arn:aws:lambda:us-east-1:ACCOUNT:layer:ql4b-shell-htmlq:1
functions:
handler:
environment:
PATH: "/opt/bin:${env:PATH}"
# Build specific layer
cd qrencode && ./build.sh
# Build all layers
./scripts/build-all.sh
# Deploy layer to AWS
./scripts/deploy-layer.sh qrencode
All layers follow the same structure:
/opt/
├── bin/ # Executable binaries
└── lib/ # Shared libraries (if needed)
Binaries are placed in /opt/bin
and automatically available when you add /opt/bin
to your PATH
.
# In your Lambda function
api_handler() {
local text="$1"
qrencode -o /tmp/qr.png "$text"
echo "QR code generated at /tmp/qr.png"
}
# Extract data from HTML
api_handler() {
local html="$1"
echo "$html" | htmlq '.title' --text
}
# Make HTTP requests
api_handler() {
local response=$(http-cli --header "Content-Type: application/json" https://api.example.com)
echo "$response" | jq '.data'
}
# Find patterns in text
api_handler() {
local text="$1"
echo "$text" | pcre2grep -o "[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}" --ignore-case
}
# Generate a UUID
api_handler() {
local uuid=$(uuidgen)
echo "Generated UUID: $uuid"
}
Each layer includes:
- Dockerfile - Multi-stage build for static binaries
- build.sh - Build and package script
- README.md - Usage documentation
- Docker
- AWS CLI (for deployment)
- zip utility
# Reference pre-built layer
data "aws_lambda_layer_version" "qrencode" {
layer_name = "ql4b-shell-qrencode"
}
# Use in function
resource "aws_lambda_function" "handler" {
layers = [data.aws_lambda_layer_version.qrencode.arn]
environment {
variables = {
PATH = "/opt/bin:${env:PATH}"
}
}
}
To add a new layer:
- Create directory with layer name
- Add Dockerfile with multi-stage build
- Create build.sh script
- Add README.md with usage examples
- Test with lambda-shell-runtime
- Runtime:
provided.al2023
- Architecture:
arm64
,x86_64
- Compatible with: lambda-shell-runtime
Part of the cloudless ecosystem.