Transcript
Page 1: Serverless NodeJS With AWS Lambda

Going ServerlessWITH AWS LAMBDA + NODEJS

JSJakartaJakarta JavaScript User Group

Page 2: Serverless NodeJS With AWS Lambda

ABOUT ME

HI, I’M RIZA

[email protected]

facebook.com/rizafahmi

github.com/rizafahmi

medium.com/@rizafahmi22

@rizafahmi22

appscoast.id

Page 3: Serverless NodeJS With AWS Lambda

Nov ‘13First Meetup

1.459Members

26Meetup Events

Held

100-ishAttendees per month

meetup.com/JakartaJS

JSJakartaJakarta JavaScript User Group

Page 4: Serverless NodeJS With AWS Lambda
Page 5: Serverless NodeJS With AWS Lambda

https://meetup.com/JakartaJS

https://jakartajs-join.herokuapp.com

JSJakartaJakarta JavaScript User Group

Page 6: Serverless NodeJS With AWS Lambda

Serverless

Page 7: Serverless NodeJS With AWS Lambda

“A New Cloud Computing Trend That Changes The Way You Think About

Writing And Maintaining Applications”

Tomasz JanczukChief Architect for Webtasks at Auth0

Page 8: Serverless NodeJS With AWS Lambda

The Pieces

Page 9: Serverless NodeJS With AWS Lambda

Lambda

Page 10: Serverless NodeJS With AWS Lambda

EC2

EC2 ContainerService

ElasticBeanstalk

Lambda

What Lambda Really Is

Page 11: Serverless NodeJS With AWS Lambda

Why You Should Use Lambda

Auto Scaling

Secure

Page 12: Serverless NodeJS With AWS Lambda

Autoscale

Page 13: Serverless NodeJS With AWS Lambda

Autoscale All The Way!

Page 14: Serverless NodeJS With AWS Lambda

2010

2014 AWS Lambda

2016 Google Cloud FunctionsMicrosoft Azure Functions

2015 Webtask RadTonicDev

Functions Service Timeline

Page 15: Serverless NodeJS With AWS Lambda

API Gateway

Page 16: Serverless NodeJS With AWS Lambda

Databases

Page 17: Serverless NodeJS With AWS Lambda

Other Services

Page 18: Serverless NodeJS With AWS Lambda

“Serverless” Infrastructure

Page 19: Serverless NodeJS With AWS Lambda

Use Cases

Page 20: Serverless NodeJS With AWS Lambda

Scalable API

Page 21: Serverless NodeJS With AWS Lambda

Scheduled Tasks

Page 22: Serverless NodeJS With AWS Lambda

Indexing and Sync

Page 23: Serverless NodeJS With AWS Lambda

Automation and iOT

Page 24: Serverless NodeJS With AWS Lambda

Audit and Notification

Page 25: Serverless NodeJS With AWS Lambda

Pricing

Page 26: Serverless NodeJS With AWS Lambda

Free Tier

1M Request3M Seconds

of compute time

Page 27: Serverless NodeJS With AWS Lambda

Lambda FunctionOur very first

Page 28: Serverless NodeJS With AWS Lambda

Getting Started

Page 29: Serverless NodeJS With AWS Lambda

Choose Your Weapon

Page 30: Serverless NodeJS With AWS Lambda

Triggers

Page 31: Serverless NodeJS With AWS Lambda

Write Your Code

Page 32: Serverless NodeJS With AWS Lambda

1 'use strict'; 2 console.log('Loading function'); 3 4 exports.handler = (event, context, callback) => { 5 let min = 1 6 let max = 10 7 8 let random_number = Math.floor(Math.random() * 9 max) + min 10 let mark = "" 11 for (let i=min; i<random_number; i ++) 12 mark = mark + "!" 13 14 callback(null, "Hello Bandung" + mark) 15 }

Zooming in to code…

Page 33: Serverless NodeJS With AWS Lambda

Setting it up!

Page 34: Serverless NodeJS With AWS Lambda

Test it

Page 35: Serverless NodeJS With AWS Lambda

Connecting Lambda To API Gateway

Page 36: Serverless NodeJS With AWS Lambda

Create New API

Page 37: Serverless NodeJS With AWS Lambda

Connect To Lambda Function

Page 38: Serverless NodeJS With AWS Lambda

Publish it

Page 39: Serverless NodeJS With AWS Lambda

Test it

Page 40: Serverless NodeJS With AWS Lambda

Slack BotServerless

Page 41: Serverless NodeJS With AWS Lambda

Add Slack WebHook Config

Page 42: Serverless NodeJS With AWS Lambda
Page 43: Serverless NodeJS With AWS Lambda

The Code 1 const AWS = require('aws-sdk') 2 const db = new AWS.DynamoDB.DocumentClient({region: 'ap-southeast-1'}) 3 4 exports.handler = (event, context, callback) => { 5 console.log(event) 6 if (event.user_name) { 7 const params = { 8 Item: { 9 date: Date.now(), 10 user_name: event.user_name 11 }, 12 TableName: 'report_log' 13 } 14 db.put(params, (err, data) => { 15 context.succeed({ 16 "response_type": "in_channel", 17 "text": "Hi " + event.user_name +"! It's time for standup meeting." 18 }) 19 }) 20 } 21 };

Page 44: Serverless NodeJS With AWS Lambda

Setting Up The Database

Page 45: Serverless NodeJS With AWS Lambda

Setting Up The Database

Page 46: Serverless NodeJS With AWS Lambda

Permission To Use The DB

Page 47: Serverless NodeJS With AWS Lambda

The Trigger

Page 48: Serverless NodeJS With AWS Lambda

Publish it

Page 49: Serverless NodeJS With AWS Lambda

Hook it

Page 50: Serverless NodeJS With AWS Lambda

Hook it

Page 51: Serverless NodeJS With AWS Lambda

Run it

Page 52: Serverless NodeJS With AWS Lambda

Our Autoscaling And Maintenance Free Bot Is Finished

Now Let’s Build Skynet!

Page 53: Serverless NodeJS With AWS Lambda

JSJakartaJakarta JavaScript User Group


Top Related