3. What Is Serverless?
• The ability to expose a single function, run in on a
shared server, and pay only for the milliseconds it takes
to execute.
• A way to host and run your code without having to
think about servers.
• A command line tool that simplifies building and
deploying serverless functions (serverless framework).
github.com/serverless/serverless
4. A Few Good Resources
• Fearless JVM Lambdas.
• martinfowler.com Serverless Architectures.
https://martinfowler.com/articles/serverless.html
• AWS Info page on serverless.
https://aws.amazon.com/serverless/
https://www.youtube.com/watch?v=GINI0T8FPD4
5. Brief Aside On Serverless
JVM Clojure
• JVM Lambda starter templates:
• lambada
• In general nodejs shown to start
faster from a “cold start”.
• lein-lambda
• For heavy processing serverless
functions, JVM may execute faster.
8. Lein-Cljs-Lambda
• A leiningen plugin by nervous.io (moea).
• Used in both serverless-cljs and cljs-lambda projects.
• Constructs the service’s final build artifacts.
https://github.com/nervous-systems/cljs-lambda
9. CLJS-Lambda
• Library of “ClojureScript utilities for AWS Lambda”.
• Dependency of both starter projects.
• Exposes macros such as deflambda and defgateway.
10. CLJS-Lambda
Lein Template
• A realistic example of a project that uses lein-cljs-lambda.
• Somewhat complex, makes use of core.async, promesa,
multimethods, and nodejs “fs”.
• Fresh scaffold gives you the “magic word” example.
• Comes with doo unit test setup out of the box.
12. Serverless-CLJS
• Barebones function that echoes the request object.
• Comes with a preconfigured serverless.yml file.
• Can automate a lot of setup and configuration done in the
AWS console.
• Great for beginners who just want a “hello world” example.
13. Serverless-Cljs Commands
• Create production build & deploy to AWS:
• Then invoke the deployed function:
but with an object more like this:
18. Configuring Your AWS Role
In Local Command Shell
• Need keys to deploy to AWS from command line.
• Get “Access Key” and “Secret Access Key in AWS”
console: My Security Credentials -> Access Keys
• Easiest way to configure user is with aws cli.
• Cljs-lambda starter also comes with helper command:
19. Calling Functions Locally
• Start lumo with lein dependencies.
• Load file into the REPL.
• Load the file’s namespace into the REPL.
20. Automated Testing
• Cljs-lambda comes with doo unit testing setup
(not difficult to add to serverless-cljs scaffold either).
• Easiest way to e2e test: deploy the function and call it
from command line, postman, AWS console, etc.
• Write a script (in any language that supports REST calls)
that calls the live function with various inputs, expecting
desired outputs.