Do have some code to show?
If you are doing it from scratch then one way would be to...
1. add gen-class to your target namespace definition. Say "my.lambda.handler"
2. Call compile as part of your build. ie (compile 'my.lambda.handler)
3. Make sure you package up the "compiled" handler from above into your artefact.
Your handler name should be the package name.
I used the same process when I had to create servlets for google app engine and I was only using tools deps so you can see an example of the above here.
I was able to figure this out by building my package with pack
: https://github.com/juxt/pack.alpha
build my package:
# clojure -A:aot
# clojure -A:pack mach.pack.alpha.aws-lambda -C:aot lambda.zip
run it locally:
sam local invoke HelloWorldFunction --event event.json
spits out this:
2019-06-09 19:22:28 Invoking clj.core::handler (java8)
2019-06-09 19:22:29 Decompressing /root/code/clj/lambda.zip
Fetching lambci/lambda:java8 Docker container image......
2019-06-09 19:22:30 Mounting /tmp/tmp9_3_pwg7 as /var/task:ro,delegated inside runtime container
START RequestId: b8bb2ac0-d515-4f89-944c-fb2c15b40936 Version: $LATEST
END RequestId: b8bb2ac0-d515-4f89-944c-fb2c15b40936
REPORT RequestId: b8bb2ac0-d515-4f89-944c-fb2c15b40936 Duration: 15.93 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 8 MB
"Hello World!"
code looks like this:
(ns clj.core
(:gen-class
:methods [^:static [handler [] String]]))
(defn -handler []
(str "Hello World!"))
I'm using pack and it works 🙂
has anyone had any luck locally emulating alb's lambda integration? sam supports apigw, but that's different (no (proxy+)
, you always get the entire path)