Slide 1

Slide 1 text

Amazon API Gateway and AWS Lambda: Better Together Danilo Poccia AWS Technical Evangelist @danilop danilop

Slide 2

Slide 2 text

You Want to Build Your Brand New Application

Slide 3

Slide 3 text

Application
 +
 Data

Slide 4

Slide 4 text

Application
 +
 Data Websites Mobile
 Apps Wearable

Slide 5

Slide 5 text

Application Data Websites Mobile
 Apps Wearable

Slide 6

Slide 6 text

Application Files DB Content +
 Some API Calls API Calls Websites Mobile
 Apps Wearable

Slide 7

Slide 7 text

Application Files DB API Calls Websites (JavaScript Apps) Mobile
 Apps Wearable JavaScript API Calls

Slide 8

Slide 8 text

Application Files DB API Calls Websites (JavaScript Apps) Mobile
 Apps Wearable Services API Calls JavaScript API Calls

Slide 9

Slide 9 text

Application Files DB API Calls Websites (JavaScript Apps) Mobile
 Apps Wearable Services API Calls JavaScript Authentication
 & Authorization Caching & Throttling Business
 Logic API Calls

Slide 10

Slide 10 text

Application DB API Calls Websites (JavaScript Apps) Mobile
 Apps Wearable Services API Calls JavaScript Files Amazon S3 Amazon DynamoDB Authentication & Authorization Amazon
 Cognito Business Logic AWS
 Lambda Caching & Throttling Amazon API
 Gateway API Calls

Slide 11

Slide 11 text

How Does It Works?

Slide 12

Slide 12 text

X Authentication Providers End Users User
 Credentials Authentication
 Token Amazon Cognito
 Identity Broker Identity Pool Id (Token) Identity Id
 AWS Temp Credentials (Depending on
 Auth / Unauth Role) Access to
 AWS Services (Including Amazon
 API Gateway) Identity Id AWS Temp Credentials Amazon S3 Amazon
 DynamoDB Amazon
 Mobile Analytics Amazon Cognito
 Sync Store K / V Authentication & Authorization Amazon
 Cognito Check Token

Slide 13

Slide 13 text

X End Users User
 Credentials Authentication
 Token Amazon Cognito
 Identity Broker Identity Pool Id (Token) Identity Id
 AWS Temp Credentials (Depending on
 Auth / Unauth Role) Access to
 AWS Services (Including Amazon
 API Gateway) Identity Id AWS Temp Credentials Amazon S3 Amazon
 DynamoDB Amazon
 Mobile Analytics Amazon Cognito
 Sync Store K / V Custom
 Authentication Service Get Token Token Authentication & Authorization Amazon
 Cognito

Slide 14

Slide 14 text

Amazon
 CloudFront API Gateway
 Cache Amazon
 CloudWatch Monitoring & Logs Endpoints on
 Amazon EC2 or AWS Elastic Beanstalk Internet Any other publicly
 accessible endpoint AWS Lambda
 Functions Caching & Throttling Amazon API
 Gateway X Access to
 API Method

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Managed Cache to Store API Responses
 Reduced Latency and DDoS Protection through Amazon CloudFront
 SDK Generation for iOS, Android and JavaScript HTTP 429 Response for API Throttling (Managed by the SDK)
 Swagger Support
 Request / Response Data Transformation and API Mocking

Slide 17

Slide 17 text

Business Logic AWS
 Lambda AWS Lambda
 Functions Amazon
 API Gateway Amazon S3 Amazon
 DynamoDB Amazon Cognito
 Sync Store K / V Amazon
 SNS Amazon
 Kinesis Alexa Skills Kit (ASK) Alexa Voice Service (AVS) HTTPS
 Invoke Custom Events HTTPS
 REST API Call

Slide 18

Slide 18 text

console.log('Loading function'); exports.handler = function(event, context) { console.log('value1 =', event.key1); console.log('value2 =', event.key2); console.log('value3 =', event.key3); // Echo back the first key value context.succeed(event.key1); // context.fail('Something went wrong'); };

Slide 19

Slide 19 text

Build Back-end Services that Perform at Scale Respond Quickly to New Information Run Your Code without Managing Infrastructure Cost-effective and Efficient

Slide 20

Slide 20 text

Amazon API Gateway + AWS Lambda

Slide 21

Slide 21 text

Resource + HTTP Verb ➔ Method

Slide 22

Slide 22 text

Resource + HTTP Verb ➔ Method /books + GET ➔ GetAllBooks

Slide 23

Slide 23 text

Resource + HTTP Verb ➔ Method /books + GET ➔ GetAllBooks /books + POST ➔ CreateNewBook

Slide 24

Slide 24 text

Resource + HTTP Verb ➔ Method /books + GET ➔ GetAllBooks /books + POST ➔ CreateNewBook /books/{id} + GET ➔ GetBookById /books/{id} + PUT ➔ CreateOrUpdateBookById /books/{id} + DELETE ➔ DeleteBookById

Slide 25

Slide 25 text

Let’s Put Everything Together

Slide 26

Slide 26 text

Media Sharing Application

Slide 27

Slide 27 text

λ λ λ Amazon
 API Gateway λ λ λ λ Bucket Usage
 Table Media Metadata Table User Stat Table User
 Location Table K / V λ λ λ Amazon Cognito
 Identity Broker Amazon Cognito
 Sync Store Amazon
 SNS Amazon
 Kinesis Media
 Bucket Log Table Authentication & Authorization Upload Picture / Video Update Bucket Usage Check Bucket Usage Delete “Over Quota” Media Send Notification to User / Application Extract Metadata and Write on DB Update User Statistics Call REST API to Get Media Description Upload Location Info Update User Location Look for Users or Media Near Current Location Call REST API to Get User Info Sync Media and User Rating Write History of Changes Check and Update Ratings Invoke Read Write / Send

Slide 28

Slide 28 text

λ λ λ λ λ λ λ λ λ λ

Slide 29

Slide 29 text

Microservice Architecture λ λ λ λ λ λ λ λ λ λ

Slide 30

Slide 30 text

Focus on You Idea

Slide 31

Slide 31 text

aws.amazon.com/free

Slide 32

Slide 32 text

Amazon API Gateway and AWS Lambda: Better Together Danilo Poccia AWS Technical Evangelist @danilop danilop