A kit to package Clojure(Script) code as AWS Lambda functions, with a focus on eliminting boilerplate, rather than on deployment (for which AWS' CloudFormation, CLI and SDKs all do an admirible job).
Enrich the boot-cljs .cljs.edn build spec with an entry that describes the
Lambda entry point. Kit configuration is sought under the key
:boot-aws-lambda-kit/handler
, with the value a map that defines the Lambda
entry point; the name of the ClojureScript function to be used, and how it
should be exported in the compiled Javascript module. For example (from the
Hello, Lambda example)
{:require [hellolambda.core]
:boot-aws-lambda-kit/handler {:fn hellolambda.core/main :as handler}
:compiler-options {:target :nodejs}}
Using a Boot task like
(core/deftask build
[]
(comp (cljs :ids #{"hellolambda"}
:optimizations :none
:compiler-options {:target :nodejs})
(boot-aws-lambda-kit.core/handler:cljs :ids #{"hellolambda"})
(task/jar :file "hellolambda.zip")
(task/target :dir #{"target"})))
will produce output simiar to
Compiling ClojureScript...
• hellolambda.js
Generating AWS Lambda for build "hellolambda"
Exporting hellolambda.core/main as AWS Lambda handler hellolambda.handler
Writing hellolambda.zip...
and a zip that can be uploaded to S3, or to Lambda directly via the console,
and installed with the handler name hellolambda.handler
; the CLJS build id
(the name of the .cljs.edn build spec file) defines the Javascript module name,
and the [:boot-aws-lambda-kit/handler :as]
key the function name.
Published under the 2-clause BSD license.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close