SlideShare a Scribd company logo
Serverless Adventures
with AWS Lambda and
Clojure
________ ______
__ ___/______________ ________________ /___________________
_____ _ _ _ ___/_ | / / _ _ ___/_ /_ _ _ ___/_ ___/
____/ // __/ / __ |/ // __/ / _ / / __/(__ )_(__ )
/____/ ___//_/ _____/ ___//_/ /_/ ___//____/ /____/
.d8b. d8888b. db db d88888b d8b db d888888b db db d8888b. d88888b .d8888. db d8b db d888888b d888888b db db
d8' `8b 88 `8D 88 88 88' 888o 88 `~~88~~' 88 88 88 `8D 88' 88' YP 88 I8I 88 `88' `~~88~~' 88 88
88ooo88 88 88 Y8 8P 88ooooo 88V8o 88 88 88 88 88oobY' 88ooooo `8bo. 88 I8I 88 88 88 88ooo88
88~~~88 88 88 `8b d8' 88~~~~~ 88 V8o88 88 88 88 88`8b 88~~~~~ `Y8b. Y8 I8I 88 88 88 88~~~88
88 88 88 .8D `8bd8' 88. 88 V888 88 88b d88 88 `88. 88. db 8D `8b d8'8b d8' .88. 88 88 88
YP YP Y8888D' YP Y88888P VP V8P YP ~Y8888P' 88 YD Y88888P `8888Y' `8b8' `8d8' Y888888P YP YP YP
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ │
│ │
│ ___ ____ __ ____ _______. __ ___ .___ ___. .______ _______ ___ │
│ /    /  / / / | | | /  | / | | _  |  /  │
│ / ^   / / / | (----` | | / ^  |  / | | |_) | | .--. | / ^  │
│ / /_   /   | | / /_  | |/| | | _ < | | | | / /_  │
│ / _____   / / .----) | | `----./ _____  | | | | | |_) | | '--' | / _____  │
│ /__/ __ &&&&&&&&&&/ |_______/ |_______/__/ __ |__| |__| |______/ |_______/ /__/ __ │
│ &::::::::::& │
│ &::::&&&:::::& ╔════════════════════════════════════════════════════════════════════════════════╗ │
└────────────────&::::&───&::::&────╣ ╠──┘
&::::& &::::& ║ ║
&::::&&&::::& ║ ______ __ ______ __ __ __ .______ _______ ║
&::::::::::& ║ / || | / __  | | | | | | | _  | ____| ║
&:::::::&& ║ | ,----'| | | | | | | | | | | | | |_) | | |__ ║
&::::::::& &&&& ║ | | | | | | | | .--. | | | | | | | / | __| ║
&:::::&&::& &:::& ║ | `----.| `----.| `--' | | `--' | | `--' | | | ----.| |____ ║
&:::::& &::&&:::&& ║ ______||_______| ______/ ______/ ______/ | _| `._____||_______| ║
&:::::& &:::::& ║ ║
&:::::& &::::& ║ ║
&::::::&&&&::::::&& ╚════════════════════════════════════════════════════════════════════════════════╝
&&::::::::&&&::::&
&&&&&&&& &&&&&
Lars Trieloff
!❤
! @trieloff
!" @trieloff
!"
!"#$%&'
!
What?
Excel + HTTP = Excelsior
!"
github.com/trieloff/excelsior
!
Why?
! Clojure
λ !
! 12 ✕
12factor.net
! Swagger
swagger.io
!"?
AWS Lambda!
!" = #
!" = #
!"
AWS λ + Clojure λ = ♥
!
Sounds good.
Sounds too good.
Sounds too good to be true.
If something sounds too
good to be true, it
probably is.
┌─────────────┐
│ │
│ │
│ Clojure │
│ ┌─────┼───────┐
│ │ ! │ │
└───────┼─────┘ │
│ AWS Lambda │
│ │
│ │
└─────────────┘
!
How?
→ ! github.com/metosin/compojure-api
→ " github.com/jpb/ring-aws-lambda-adapter
→ # github.com/mjul/docjure
→ ⭕ circleci.com
→ % github.com/mhjort/lein-clj-lambda
┌────────────────────────┐ ┌────────────────────────┐
│ ┌────────────────────┐ │ │ │
│ │ ┌────────────────┐ │ │ │ │
│ │ │ ┌────────────┐ │ │ │ │ │
│ │ │ │ Docjure !│ │ │ │ │ │
│ │ │ └────────────┘ │ │ │ ┌────────────┐ │ AWS API Gateway │
│ │ │ My code " │ │ │ ┌────────▶│swagger.json│─────Import─────▶│ │
│ │ └────────────────┘ │ │ Export └────────────┘ │ │
│ │ Compojure API # ├─┼─────┘ │ │
│ └────────────────────┘ │ │ │
│ Ring Lambda Adapter $ │ │ │
└────────────────────────┘ └────────────────────────┘
│ │
│ Proxy
│ │
│ ▼
│ ┌────────────────────────┐
│ │ │
│ │ │
│ │ │
│ │ │
│ ┌────────────┐ │ AWS Lambda │
└───────────Build % ─────▶│ server.jar │────Deploy──────▶│ │
└────────────┘ │ │
│ │
│ │
│ │
└────────────────────────┘
!
Problems?
┌─────────────┐
│ │
│ │
│ Clojure │
│ ┌─────┼───────┐
│ │!"#│ │
└───────┼─────┘ │
│ AWS Lambda │
│ │
│ │
└─────────────┘
!"
github.com/trieloff/lein-aws-apigateway
!"
AWS API Gateway
!"
AWS IAM Permissions
Execution failed due to configuration error: Invalid
permissions on Lambda function
aws lambda add-permission 
--function-name <name> 
--statement-id <someid> 
--action "lambda:*" 
--principal "apigateway.amazonaws.com"
! docs.aws.amazon.com/cli/latest/reference/
lambda/add-permission.html
!
Tips?
Think small
100 LOC should be
enough for a Lambda
function. !
Think
modular
Two tiny functions are
better than one large
function. !
!"
github.com/trieloff/salvador
Think
Stateless
simplicity, performance,
composablity ☠
Be lazy
Sit, don’t stand on the
shoulders of giants. Re-
use, don’t re-invent. ♻
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ │ │ │ │ │
│ Typeform │───Redirect──▶│ Excelsior │───Redirect──▶│ Salvador │
│ │ │ │ │ │
└──────────────────┘ └──────────────────┘ └──────────────────┘
▲ ▲
│ │
Spreadsheet Template
│ │
│ │
┌──────────────────┐ ┌──────────────────┐
│ │ │ │
│ S3 │ │ S3 │
│ │ │ │
└──────────────────┘ └──────────────────┘
Smile & Share
Community eats code for
breakfast. ☕
!
⏰
AWS λ + Clojure λ = ♥
! Rainbow Parentheses make " #
))))))))))))*

More Related Content

PDF
Genesis200902 sugyan
PDF
Introduction to Japanese Morphological Analysis
PDF
Automated decision making with predictive applications – Big Data Brussels
PDF
Big Data Munich – Decision Automation and Big Data
PDF
Big Data Berlin – Automating Decisions is the Next Frontier for Big Data
PDF
Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...
PDF
Web Forms 2.0
PDF
Smartcon 2015 – Automated Decisions in the Supply Chain
Genesis200902 sugyan
Introduction to Japanese Morphological Analysis
Automated decision making with predictive applications – Big Data Brussels
Big Data Munich – Decision Automation and Big Data
Big Data Berlin – Automating Decisions is the Next Frontier for Big Data
Data Natives 2015: Predictive Applications are Going to Steal Your Job: this ...
Web Forms 2.0
Smartcon 2015 – Automated Decisions in the Supply Chain

Viewers also liked (20)

PDF
How to get value out of data
PDF
Business Reasons for Predictive Applications
PDF
Automated Decision Making with Predictive Applications – Big Data Düsseldorf
PDF
Automated Decision making with Predictive Applications – Big Data Hamburg
PDF
AMEX Meetings&Events 2015 Global Meetings & Events Forecast
PDF
Blue Yonder - NOAH16 London
PDF
Forecasting - MENA 2012 Conference
PDF
Automated decision making with predictive applications – Big Data Amsterdam
PPTX
How to market and sell unbundled travel
PDF
ADDD (Automated Data Driven Decisions) – How To Make it Work
PDF
Automated decision making with predictive applications – Big Data Frankfurt
PPTX
Forecasting and Managing Passenger Growth
PDF
Airport forecasting
PPTX
Presentation on forecasting
PDF
Airline and Airport Big Data: Impact and Efficiencies
PPT
Marketing Airline
PPTX
A4A Industry Review and Outlook
PDF
Big Data For Flight Delay Report
PDF
Big data analysis concepts and references
PPTX
A Brief History of Big Data
How to get value out of data
Business Reasons for Predictive Applications
Automated Decision Making with Predictive Applications – Big Data Düsseldorf
Automated Decision making with Predictive Applications – Big Data Hamburg
AMEX Meetings&Events 2015 Global Meetings & Events Forecast
Blue Yonder - NOAH16 London
Forecasting - MENA 2012 Conference
Automated decision making with predictive applications – Big Data Amsterdam
How to market and sell unbundled travel
ADDD (Automated Data Driven Decisions) – How To Make it Work
Automated decision making with predictive applications – Big Data Frankfurt
Forecasting and Managing Passenger Growth
Airport forecasting
Presentation on forecasting
Airline and Airport Big Data: Impact and Efficiencies
Marketing Airline
A4A Industry Review and Outlook
Big Data For Flight Delay Report
Big data analysis concepts and references
A Brief History of Big Data
Ad

More from Lars Trieloff (17)

PDF
Putting the F in FaaS: Functional Compositional Patterns in a Serverless World
PDF
Automated decision making using Predictive Applications – Big Data Paris
PDF
Automated decision making with big data – Big Data Vienna
PDF
10 Things I Learned About Pricing – Product Camp Berlin 2014
PDF
The DNA of Marketing
PDF
Cross community campaigns with CQ5
PDF
Mastering the customer engagement ecosystem with CQ5
PDF
Advanced Collaboration And Beyond
PDF
Getting Into The Flow With CQ DAM
PDF
The Zero Bullshit Architecture
PDF
Creating Value In Social Networking
PDF
5 Ways To Build Asset Centric Applications
PDF
REST and AJAX Reconciled
PDF
µjax in 30 minutes (for Stockholm)
PDF
µjax in 30 minutes
PDF
Living in a multiligual world: Internationalization for Web 2.0 Applications
PDF
Mindquarry For Cocoon Users
Putting the F in FaaS: Functional Compositional Patterns in a Serverless World
Automated decision making using Predictive Applications – Big Data Paris
Automated decision making with big data – Big Data Vienna
10 Things I Learned About Pricing – Product Camp Berlin 2014
The DNA of Marketing
Cross community campaigns with CQ5
Mastering the customer engagement ecosystem with CQ5
Advanced Collaboration And Beyond
Getting Into The Flow With CQ DAM
The Zero Bullshit Architecture
Creating Value In Social Networking
5 Ways To Build Asset Centric Applications
REST and AJAX Reconciled
µjax in 30 minutes (for Stockholm)
µjax in 30 minutes
Living in a multiligual world: Internationalization for Web 2.0 Applications
Mindquarry For Cocoon Users
Ad

Serverless adventures with AWS Lambda and Clojure

  • 1. Serverless Adventures with AWS Lambda and Clojure
  • 2. ________ ______ __ ___/______________ ________________ /___________________ _____ _ _ _ ___/_ | / / _ _ ___/_ /_ _ _ ___/_ ___/ ____/ // __/ / __ |/ // __/ / _ / / __/(__ )_(__ ) /____/ ___//_/ _____/ ___//_/ /_/ ___//____/ /____/ .d8b. d8888b. db db d88888b d8b db d888888b db db d8888b. d88888b .d8888. db d8b db d888888b d888888b db db d8' `8b 88 `8D 88 88 88' 888o 88 `~~88~~' 88 88 88 `8D 88' 88' YP 88 I8I 88 `88' `~~88~~' 88 88 88ooo88 88 88 Y8 8P 88ooooo 88V8o 88 88 88 88 88oobY' 88ooooo `8bo. 88 I8I 88 88 88 88ooo88 88~~~88 88 88 `8b d8' 88~~~~~ 88 V8o88 88 88 88 88`8b 88~~~~~ `Y8b. Y8 I8I 88 88 88 88~~~88 88 88 88 .8D `8bd8' 88. 88 V888 88 88b d88 88 `88. 88. db 8D `8b d8'8b d8' .88. 88 88 88 YP YP Y8888D' YP Y88888P VP V8P YP ~Y8888P' 88 YD Y88888P `8888Y' `8b8' `8d8' Y888888P YP YP YP ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ │ │ │ │ ___ ____ __ ____ _______. __ ___ .___ ___. .______ _______ ___ │ │ / / / / / | | | / | / | | _ | / │ │ / ^ / / / | (----` | | / ^ | / | | |_) | | .--. | / ^ │ │ / /_ / | | / /_ | |/| | | _ < | | | | / /_ │ │ / _____ / / .----) | | `----./ _____ | | | | | |_) | | '--' | / _____ │ │ /__/ __ &&&&&&&&&&/ |_______/ |_______/__/ __ |__| |__| |______/ |_______/ /__/ __ │ │ &::::::::::& │ │ &::::&&&:::::& ╔════════════════════════════════════════════════════════════════════════════════╗ │ └────────────────&::::&───&::::&────╣ ╠──┘ &::::& &::::& ║ ║ &::::&&&::::& ║ ______ __ ______ __ __ __ .______ _______ ║ &::::::::::& ║ / || | / __ | | | | | | | _ | ____| ║ &:::::::&& ║ | ,----'| | | | | | | | | | | | | |_) | | |__ ║ &::::::::& &&&& ║ | | | | | | | | .--. | | | | | | | / | __| ║ &:::::&&::& &:::& ║ | `----.| `----.| `--' | | `--' | | `--' | | | ----.| |____ ║ &:::::& &::&&:::&& ║ ______||_______| ______/ ______/ ______/ | _| `._____||_______| ║ &:::::& &:::::& ║ ║ &:::::& &::::& ║ ║ &::::::&&&&::::::&& ╚════════════════════════════════════════════════════════════════════════════════╝ &&::::::::&&&::::& &&&&&&&& &&&&&
  • 5. !
  • 7. Excel + HTTP = Excelsior
  • 9. !
  • 10. Why?
  • 12. λ !
  • 15. !"?
  • 19. !"
  • 20. AWS λ + Clojure λ = ♥
  • 21. !
  • 24. Sounds too good to be true.
  • 25. If something sounds too good to be true, it probably is.
  • 26. ┌─────────────┐ │ │ │ │ │ Clojure │ │ ┌─────┼───────┐ │ │ ! │ │ └───────┼─────┘ │ │ AWS Lambda │ │ │ │ │ └─────────────┘
  • 27. !
  • 28. How?
  • 29. → ! github.com/metosin/compojure-api → " github.com/jpb/ring-aws-lambda-adapter → # github.com/mjul/docjure → ⭕ circleci.com → % github.com/mhjort/lein-clj-lambda
  • 30. ┌────────────────────────┐ ┌────────────────────────┐ │ ┌────────────────────┐ │ │ │ │ │ ┌────────────────┐ │ │ │ │ │ │ │ ┌────────────┐ │ │ │ │ │ │ │ │ │ Docjure !│ │ │ │ │ │ │ │ │ └────────────┘ │ │ │ ┌────────────┐ │ AWS API Gateway │ │ │ │ My code " │ │ │ ┌────────▶│swagger.json│─────Import─────▶│ │ │ │ └────────────────┘ │ │ Export └────────────┘ │ │ │ │ Compojure API # ├─┼─────┘ │ │ │ └────────────────────┘ │ │ │ │ Ring Lambda Adapter $ │ │ │ └────────────────────────┘ └────────────────────────┘ │ │ │ Proxy │ │ │ ▼ │ ┌────────────────────────┐ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌────────────┐ │ AWS Lambda │ └───────────Build % ─────▶│ server.jar │────Deploy──────▶│ │ └────────────┘ │ │ │ │ │ │ │ │ └────────────────────────┘
  • 31. !
  • 33. ┌─────────────┐ │ │ │ │ │ Clojure │ │ ┌─────┼───────┐ │ │!"#│ │ └───────┼─────┘ │ │ AWS Lambda │ │ │ │ │ └─────────────┘
  • 37. Execution failed due to configuration error: Invalid permissions on Lambda function aws lambda add-permission --function-name <name> --statement-id <someid> --action "lambda:*" --principal "apigateway.amazonaws.com" ! docs.aws.amazon.com/cli/latest/reference/ lambda/add-permission.html
  • 38. !
  • 39. Tips?
  • 40. Think small 100 LOC should be enough for a Lambda function. !
  • 41. Think modular Two tiny functions are better than one large function. !
  • 44. Be lazy Sit, don’t stand on the shoulders of giants. Re- use, don’t re-invent. ♻
  • 45. ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐ │ │ │ │ │ │ │ Typeform │───Redirect──▶│ Excelsior │───Redirect──▶│ Salvador │ │ │ │ │ │ │ └──────────────────┘ └──────────────────┘ └──────────────────┘ ▲ ▲ │ │ Spreadsheet Template │ │ │ │ ┌──────────────────┐ ┌──────────────────┐ │ │ │ │ │ S3 │ │ S3 │ │ │ │ │ └──────────────────┘ └──────────────────┘
  • 46. Smile & Share Community eats code for breakfast. ☕
  • 47. !
  • 48.
  • 49. AWS λ + Clojure λ = ♥