Getting started

What you need

Go 1.24 or later, since Glojure v0.7.24 needs it, plus babashka, Python 3 for the offline probe, zip, and AWS CLI v2 once you deploy. You don't need Docker unless you want LocalStack, because Go cross-compiles the Linux binary on any machine.

Probe and build locally

bb verify

bb verify runs the unit tests, then bb probe, then bb build. The probe compiles the namespaces, builds a bootstrap for your own machine and runs it against a mock of the Lambda Runtime API, which serves two events and checks both responses. The build cross-compiles dist/bootstrap for linux/arm64 and zips it into dist/lambda.zip. Set LAMBDA_ARCH=x86_64 to target Intel instead.

The first run downloads Glojure's Go module and builds its compiler into .build/glj, so expect it to take a while. Later runs reuse both.

Deploy and invoke

export AWS_PROFILE=... AWS_REGION=...
bb deploy
bb invoke

bb deploy creates an IAM role called lambda-mvp-glj-role and a function called lambda-mvp-glj on provided.al2023, or updates the code if the function exists. It reads the architecture from the binary's ELF header, so it can't disagree with the last build. LAMBDA_MVP_FUNCTION_NAME picks another name, but pick one you don't mind losing, because bb teardown deletes whatever that name points at.

bb invoke prints the response and the end of the function's log, including CloudWatch's REPORT line. The first invoke shows an Init Duration, since it started cold. bb demo builds, deploys and invokes in one go, after checking your tools and credentials.

Benchmark, then tear down

bb bench
bb teardown

Cold vs. warm boot explains the table bb bench prints. It leaves the function at the last memory tier it tried, 3008 MB by default, so tear it down when you're done. To check nothing is left:

aws lambda list-functions --query 'Functions[?starts_with(FunctionName, `lambda-mvp`)].FunctionName'
aws iam list-roles --query 'Roles[?starts_with(RoleName, `lambda-mvp`)].RoleName'