File tree 5 files changed +53
-0
lines changed
5 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ .clj-kondo /
2
+ .lsp /
3
+ .cpcache /
4
+ target /
5
+ .DS_Store
Original file line number Diff line number Diff line change
1
+ # Basic JVM Clojure lambda setup
2
+
3
+ ## Build
4
+
5
+ To build an uberjar:
6
+
7
+ ``` bash
8
+ $ clj -T:build uber
9
+ ```
10
+
11
+ Then upload the ` target/lambda-*.jar ` to your [ lambda function] ( https://docs.aws.amazon.com/lambda/latest/dg/java-package.html#java-package-console )
12
+ and off you go!
Original file line number Diff line number Diff line change
1
+ (ns build
2
+ (:require [clojure.tools.build.api :as b]))
3
+
4
+ (def lib 'my /lambda )
5
+ (def version (format " 0.1.%s" (b/git-count-revs nil )))
6
+ (def class-dir " target/classes" )
7
+ (def basis (delay (b/create-basis {:project " deps.edn" })))
8
+ (def uber-file (format " target/%s-%s-standalone.jar" (name lib) version))
9
+
10
+ (defn clean [_]
11
+ (b/delete {:path " target" }))
12
+
13
+ (defn uber [_]
14
+ (b/copy-dir {:src-dirs [" src" " resources" ]
15
+ :target-dir class-dir})
16
+ (b/compile-clj {:basis @basis
17
+ :src-dirs [" src" ]
18
+ :class-dir class-dir})
19
+ (b/uber {:class-dir class-dir
20
+ :uber-file uber-file
21
+ :basis @basis}))
Original file line number Diff line number Diff line change
1
+ {:paths [" src" ]
2
+ :deps {org.clojure/clojure {:mvn/version " 1.11.1" }
3
+ com.amazonaws/aws-lambda-java-core {:mvn/version " 1.2.3" }}
4
+ :aliases
5
+ {:build {:extra-deps {io.github.clojure/tools.build {:git/tag " v0.8.4" :git/sha " 8c3cd69" }}
6
+ :ns-default build}}}
Original file line number Diff line number Diff line change
1
+ (ns lambda
2
+ (:gen-class
3
+ :implements [com.amazonaws.services.lambda.runtime.RequestStreamHandler]))
4
+
5
+ (defn -handleRequest [_ is os _context]
6
+ (let [input (slurp is)]
7
+ (if (re-find #"error" input)
8
+ (throw (ex-info " test" {:my " error" }))
9
+ (spit os " test" ))))
You can’t perform that action at this time.
0 commit comments