Experimenting with AWS Lambda
and Clojure
.
- Ahead of time compilation (AOT) ✅
- Build an Uberjar ✅
- Build a native image with GraalVM ✅
- Run the compiled code in Docker ✅
Push the Docker file to AWS😕Add a lambda using the Docker container and test if the entry point is correct😕- Create a bash custom runtime for AWS Lambda ✅
- Deploy the custom runtime with the Clojure code compiled to a native image ✅
- Test the custom runtime locally in Docker, using a Custom Runtime image from AWS ✅
- clj-graal-docs - with an Hello World example
- Custom AWS Lambda runtimes
- Lambda Container Image Support (example with Custom Runtime)
- A GraalVM guide by Bruno Bonacci
- Building A Fast Command Line App With Clojure by Kira McLean
- How to AOT compile a Clojure application to a native binary and run it in AWS Lambda as a Docker image. by Esko Luontola
- aws-lambda-java at Docker Hub
- GraalVM and Native images
Using Clojure 1.10.2 that has GraalVM specific features/fixes.
I found out that, when running the custom runtime locally in Docker with a custom runtime image, the bootstrap
file
should be copied in a different directory than the function code - not sure how this works when only pushing a zip
to AWS.
I downloaded GraalVM, extracted the downloaded file and ran a virus scan (ClamTK). The scanner found a potential threat, that confused me:
a Node.js npm package called imurmurhash.min.js
. ClamTK status for this file was: PUA.Win.Trojan.Xored-1
.
My quick fix for this was to navigate to the graalvm-ce-java11-21.0.0.2/languages
folder and delete the entire js
folder before running any GraalVM commands.
Why was this file flagged by the virus scanner?