Lars Trierloff - Serverless Adventures with AWS Lambda and Clojure
AWS Lambda with ClaudiaJS
-
Upload
riza-fahmi -
Category
Technology
-
view
172 -
download
3
Transcript of AWS Lambda with ClaudiaJS
![Page 1: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/1.jpg)
Serverless WithLambda, NodeJS and ClaudiaJS
AWSome Meetup on 31st of October
![Page 2: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/2.jpg)
Hi, I’m Riza
![Page 3: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/3.jpg)
Serverless
![Page 4: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/4.jpg)
“A new cloud compu!ng trend that changes the way you think about wri!ng and maintaining applica!ons.”
Tomasz Janczuk
Chief Architect for Webtasks at Auth0
![Page 5: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/5.jpg)
“The essence of the serverless trend is the absence of the server concept during so"ware development.”
Tomasz Janczuk
Chief Architect for Webtasks at Auth0
![Page 6: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/6.jpg)
Faas
Amazon Lambda
Google Func!ons
Azure Func!ons
![Page 7: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/7.jpg)
GOTO; Conf 2017
"For 400.000 ac!ve user we have paid $0.53 for Lambda. Now, beat that with your hos!ng cost!"
Gojko Adzic from MindMup
Designing for the Serverless Age
h!ps://www.youtube.com/watch?v=w7X4gAQTk2E
![Page 8: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/8.jpg)
I’m sold!
![Page 9: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/9.jpg)
Really?
![Page 10: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/10.jpg)
But I Love’em
![Page 11: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/11.jpg)
Especially this
![Page 12: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/12.jpg)
Don’t you worry
![Page 13: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/13.jpg)
*Fully-managed your serverless architecture
*Required to use CloudForma"on
*Build-in support for CI/CD workflows
![Page 14: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/14.jpg)
* Golang-based framework
* Deployment op"mized
* Concurrent for quick deploy
![Page 15: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/15.jpg)
* Deployment u"lity, not a framework
* Extensions for new features
* unit-test Lambda func"ons
![Page 16: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/16.jpg)
“Serverless is like ice cream. It’s nice to talk about it, but
much be"er to try out.”
![Page 17: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/17.jpg)
The Casts
A Serverless Host
Deployment Library
Services
Database
![Page 18: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/18.jpg)
The Architecture
![Page 19: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/19.jpg)
First Act...Ac!on!!
$ vim ~/.aws/credentials
[default] aws_access_key_id = YOUR_ACCESS_KEY aws_secret_access_key = YOUR_ACCESS_SECRET
![Page 20: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/20.jpg)
Second Act...Install Claudia
$ npm install -g claudia
![Page 21: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/21.jpg)
Third Act...Write our service
$ mkdir claudia-icecream-shop $ cd claudia-icecream-shop $ npm init $ npm install aws-sdk claudia-api-builder $ vim index.js
![Page 22: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/22.jpg)
Third Act...Write our service
const ApiBuilder = require('claudia-api-builder') const AWS = require('aws-sdk') const api = new ApiBuilder() const dynamoDb = new AWS.DynamoDB.DocumentClient()
const TABLENAME = 'icecreams'
![Page 23: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/23.jpg)
Third Act...Write our service
api.post('/icecreams', request => { const params = { TableName: TABLENAME, Item: { icecreamid: request.body.id, name: request.body.name } } return dynamoDb.put(params).promise() }, { success: 201 } )
![Page 24: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/24.jpg)
Third Act...Write our service
api.get('/icecreams', request => { return dynamoDb .scan({ TableName: TABLENAME }) .promise() .then(response => response.Items) })
module.exports = api
![Page 25: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/25.jpg)
Fourth Act...Setup DynamoDB
$ mkdir policy
$ vim policy/dynamodb-policy.json
![Page 26: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/26.jpg)
Fourth Act...Setup DynamoDB
{ "Version": "2012-10-17", "Statement": [ { "Action": [ "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:Scan" ], "Effect": "Allow", "Resource": "*" } ] }
![Page 27: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/27.jpg)
Fourth Act...Setup DynamoDB
![Page 28: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/28.jpg)
Fourth Act...Setup DynamoDB
$ aws dynamodb create-table --table-name icecreams --attribute-definition \ AttributeName=icecreamid,AttributeType=S \ --key-schema \ AttributeName=icecreamid,KeyType=HASH \ --provisioned-throughput \ ReadCapacityUnits=1,WriteCapacityUnits=1 \ --region ap-southeast-1 \ --query TableDescription.TableArn --output text
![Page 29: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/29.jpg)
Fi"h Act...Time for deploy
$ claudia create --region ap-southeast-1 \
--api-module index --policies policy
![Page 30: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/30.jpg)
Fi"h Act...Time for deploy
{
"lambda": {
"role": "ice-cream-shop-executor",
"name": "ice-cream-shop",
"region": "us-east-1"
},
"api": {
"id": "your-service-id",
"module": "index",
"url": “https: //xxx.execute-api.ap-
southeast-1.amazonaws.com/latest"
}
}
![Page 31: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/31.jpg)
$ curl -H "Content-Type: application/json"
-X POST -d
‘{“icecreamId”:”123","name":"chocolate"}' \
https: //xxx.execute-api.ap-
southeast-1.amazonaws.com/latest/icecreams
Sixth Act...Trying it out
![Page 32: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/32.jpg)
Sixth Act...Trying it out
$ curl https: //xxx.execute-api.ap-
southeast-1.amazonaws.com/latest/icecreams
[{“icecreamId”: 123, “name”: “chocolate”}]
![Page 33: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/33.jpg)
Seventh Act...Some updates
$ claudia update
![Page 34: AWS Lambda with ClaudiaJS](https://reader034.fdocuments.in/reader034/viewer/2022042517/5a657fb87f8b9a931a8b61eb/html5/thumbnails/34.jpg)
That’s Pretty much it!Now go, you deserve some ice cream!
h!ps://github.com/rizafahmi/claudia-ice-cream