Liking cljdoc? Tell your friends :D


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).


Build Status Clojars Project



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 "")
        (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

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.

The code that is at the heart of boot-aws-lambda-kit predates boot-lambda's generate-cljs-lambda-index, making it a drop-in solution for other projects that already use this pattern. For new projects, boot-lambda is now a comprehensive CLJS solution, but boot-aws-lambda-kit aspires to cater for both Clojure and ClojureScript.
Primarily for the deployment of Lambda functions


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