Demo project convert text to date.
Slides of the presentation can be found here: https://www.slideshare.net/Dainius/clojure-workflow-tokenmill-by-dainius-jocas
Custom AWS Lambda runtime with the Clojure tools-deps
application compiled with GraalVM native-image
.
Set these environment variables:
- MY_AWS_DEFAULT_REGION
- MY_AWS_ACCESS_KEY_ID
- MY_AWS_SECRET_ACCESS_KEY
- MY_S3_BUCKET
- MY_S3_FOLDER
Run:
make deploy-lambda-via-container
Lambda is ready to be used. Go to your AWS Console to work with the new stack named lambda-custom-runtime-text2dateLambda
.
Most common operations are scripted in the Makefile:
make build-native-image
: inside the docker with the GraalVM builds native binary for the lambda and copies it to the project folder two files:server
andlibsunec.so
make build-lambda-zip
: inside the docker creates a custom AWS lambda runtime zip archive and copies it to the project folder as afunction.zip
file (for manual deployments).make deploy-custom-runtime-lambda
: (use it if you haveawscli
installed and configured) builds a deployable lambda zip and deploys it to AWS.make deploy-lambda-via-container
: builds lambda zip and deploys to AWS with your provided credentials (set the environment variables (e.g.(export MY_AWS_DEFAULT_REGION=eu-west-1 && <set other enviroment variables> && make deploy-lambda-via-container)
or use something like dotenv, or some other way).
This demo assumes that docker is available in the system.
- Modify
request->response
function to do the work you need. - When needed add libraries to the
deps.edn
(with a little more work Git deps from private git repositories can be achieved). - Build native image with GraalVM inside a docker
- Configure CI (for environment variables)
- Deploy to AWS Lambda
(defn request->response [request]
(let [decoded-request (json/read-value request read-mapper)]
(json/write-value-as-string decoded-request)))
.gitlab-ci.yml
file includes a demo on how the lambda can be deployed from the Gitlab CI pipeline. Create environment variables in the CI/CD setup of your project.