SlideShare a Scribd company logo
1 of 51
Download to read offline
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

Viewers also liked

How to get value out of data
How to get value out of dataHow to get value out of data
How to get value out of data
Lars Trieloff
 
Marketing Airline
Marketing AirlineMarketing Airline
Marketing Airline
zeeshanvali
 

Viewers also liked (20)

How to get value out of data
How to get value out of dataHow to get value out of data
How to get value out of data
 
Business Reasons for Predictive Applications
Business Reasons for Predictive ApplicationsBusiness Reasons for Predictive Applications
Business Reasons for Predictive Applications
 
Automated Decision Making with Predictive Applications – Big Data Düsseldorf
Automated Decision Making with Predictive Applications – Big Data DüsseldorfAutomated Decision Making with Predictive Applications – Big Data Düsseldorf
Automated Decision Making with Predictive Applications – Big Data Düsseldorf
 
Automated Decision making with Predictive Applications – Big Data Hamburg
Automated Decision making with Predictive Applications – Big Data HamburgAutomated Decision making with Predictive Applications – Big Data Hamburg
Automated Decision making with Predictive Applications – Big Data Hamburg
 
AMEX Meetings&Events 2015 Global Meetings & Events Forecast
AMEX Meetings&Events 2015 Global Meetings & Events ForecastAMEX Meetings&Events 2015 Global Meetings & Events Forecast
AMEX Meetings&Events 2015 Global Meetings & Events Forecast
 
Blue Yonder - NOAH16 London
Blue Yonder - NOAH16 LondonBlue Yonder - NOAH16 London
Blue Yonder - NOAH16 London
 
Forecasting - MENA 2012 Conference
Forecasting - MENA 2012 ConferenceForecasting - MENA 2012 Conference
Forecasting - MENA 2012 Conference
 
Automated decision making with predictive applications – Big Data Amsterdam
Automated decision making with predictive applications – Big Data AmsterdamAutomated decision making with predictive applications – Big Data Amsterdam
Automated decision making with predictive applications – Big Data Amsterdam
 
How to market and sell unbundled travel
How to market and sell unbundled travelHow to market and sell unbundled travel
How to market and sell unbundled travel
 
ADDD (Automated Data Driven Decisions) – How To Make it Work
ADDD (Automated Data Driven Decisions) – How To Make it WorkADDD (Automated Data Driven Decisions) – How To Make it Work
ADDD (Automated Data Driven Decisions) – How To Make it Work
 
Automated decision making with predictive applications – Big Data Frankfurt
Automated decision making with predictive applications – Big Data FrankfurtAutomated decision making with predictive applications – Big Data Frankfurt
Automated decision making with predictive applications – Big Data Frankfurt
 
Forecasting and Managing Passenger Growth
Forecasting and Managing Passenger GrowthForecasting and Managing Passenger Growth
Forecasting and Managing Passenger Growth
 
Airport forecasting
Airport forecastingAirport forecasting
Airport forecasting
 
Presentation on forecasting
Presentation on forecasting Presentation on forecasting
Presentation on forecasting
 
Airline and Airport Big Data: Impact and Efficiencies
Airline and Airport Big Data: Impact and EfficienciesAirline and Airport Big Data: Impact and Efficiencies
Airline and Airport Big Data: Impact and Efficiencies
 
Marketing Airline
Marketing AirlineMarketing Airline
Marketing Airline
 
A4A Industry Review and Outlook
A4A Industry Review and OutlookA4A Industry Review and Outlook
A4A Industry Review and Outlook
 
Big Data For Flight Delay Report
Big Data For Flight Delay ReportBig Data For Flight Delay Report
Big Data For Flight Delay Report
 
Big data analysis concepts and references
Big data analysis concepts and referencesBig data analysis concepts and references
Big data analysis concepts and references
 
A Brief History of Big Data
A Brief History of Big DataA Brief History of Big Data
A Brief History of Big Data
 

More from Lars Trieloff

Mastering the customer engagement ecosystem with CQ5
Mastering the customer engagement ecosystem with CQ5Mastering the customer engagement ecosystem with CQ5
Mastering the customer engagement ecosystem with CQ5
Lars Trieloff
 

More from Lars Trieloff (17)

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

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 λ = ♥