Skip to content

Instantly share code, notes, and snippets.

@lukaszkorecki
Created June 18, 2022 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszkorecki/4ddede30578bcdd00f043be861ba568f to your computer and use it in GitHub Desktop.
Save lukaszkorecki/4ddede30578bcdd00f043be861ba568f to your computer and use it in GitHub Desktop.
(defn unwrap-payload
[input]
(let [raw (json/parse-string (slurp input) true)
;; actuall notification data is wrapped in an inner json field
payload (-> raw :Records first :Sns :Message (json/parse-string true))]
payload))
(gen-class
:name "something.Core"
:implements [com.amazonaws.services.lambda.runtime.RequestStreamHandler])
(defn -handleRequest
[_this input output ctx]
(let [logger (.getLogger ctx)
payload (unwrap-payload input)
res (do-something-with-payload logger payload)]
(with-open [o (io/writer output)]
(.write o (json/generate-string {:message "ack", :result res})))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment