Babashka script packaged as AWS Lambda.
This example requires GNU Make, Docker, and AWS CLI, babashka, clojure.
Build: sam build
Deploy: sam deploy --guided
(and just sam deploy
thereafter)
Test locally: sam local invoke --event events/event-cloudwatch-event.json --debug
Provide stack
for cloudformation stack name and s3-bucket
params.
make stack="babashka-lambda" s3-bucket="my-bucket" deploy
Make sure that your provided S3 bucket, e.g. my-bucket
exists. And of course, make sure you are authorized to deploy to AWS.
make function-name=$(make get-function-name) invoke-function
The response should be similar:
{"test":"test914"}{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
Get the function name:
Open src/lambda/core.clj
and implement your handler-fn
.
handler-fn
is a function that takes in clojure map that is parsed from the request body.
make build
Will create function.zip
archive that is ready to be deployed as AWS Lambda into a custom runtime.
The contents of function.zip
are:
$ ls -a
. .. bb bootstrap cp deps.edn .gitlibs .m2 resources src
Where:
bb
: babashka binarybootstrap
: AWS Lambda entry point scriptcp
: generated classpath text filedeps.edn
.gitlibs
: directory with gitlibs.m2
: directory with Maven dependenciesresources
:src
: directory with babashka scripts