event-driven serverless apps - pop-up loft tel aviv

50
EventDriven Serverless Apps Danilo Poccia, Technical Evangelist @danilop

Upload: amazon-web-services

Post on 12-Apr-2017

318 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Event-­‐Driven  Serverless  AppsDanilo  Poccia,  Technical  Evangelist

         @danilop

Page 2: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Event-Driven in the Front End

Page 3: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Name

Email

Create New User

Submit

Check the “Name” syntax is right (only letters and spaces)

Check the “Email” syntax is right ([email protected])

Create the new user using provided Name and Email

User Interface Actions

Page 4: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Name

Email

Create New User

Submit

Check the “Name” syntax is right (only letters and spaces)

Check the “Email” syntax is right ([email protected])

Create the new user using provided Name and Email

User Interface ActionsObservers

Target Action

Page 5: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

What about the Back End ?

Page 6: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

! Users

Page 7: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Internet

! Users

Page 8: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Back End Logic

Internet

! Users

Page 9: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Back End Data

Back End Logic

Internet

! Users

Page 10: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Back End Data

Application Back End

Back End Logic

Internet

! Users

Page 11: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Application Back End" Web Browsers

Back End Data

Back End Logic

Page 12: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Application Back End" Web Browsers

# Mobile Apps Back End

Data

Back End Logic

Page 13: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Application Back End" Web Browsers

# Mobile Apps

$ IoT Devices

Back End Data

Back End Logic

Page 14: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Application Back End" Web Browsers

# Mobile Apps

$ IoT Devices

% Other Services

Back End Data

Back End Logic

Page 15: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Application Back End

Files

Databases

" Web Browsers

# Mobile Apps

$ IoT Devices

% Other Services

Back End Logic

Page 16: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

HTML, CSS, JavaScript & Multimedia Content

API Calls

Application Back End" Web Browsers

# Mobile Apps

$ IoT Devices

% Other Services

Files

Databases

Back End Logic

Page 17: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

API Calls

Application Back End

HTML, CSS, JavaScript & Multimedia Content

" Web Browsers

(JavaScript)

# Mobile Apps

$ IoT Devices

% Other Services

By using JavaScript, Web Browsers can behave

like the other clients, such as Mobile Apps

or IoT Devices

Files

Databases

Back End Logic

Page 18: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

API Calls

Application Back End

HTML, CSS, JavaScript & Multimedia Content

" Web Browsers

(JavaScript)

# Mobile Apps

$ IoT Devices

% Other Services

Files

Databases

Back End Logic

Page 19: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

API Calls

Application Back End

HTML, CSS, JavaScript & Multimedia Content

The Client Application can be a Web Browser,

a Mobile App, an IoT Device,

or another Service

We can now decouple the back end implementation

from the device used by our users

Files

Databases

Back End Logic

Page 20: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

API Calls

Application Back End

HTML, CSS, JavaScript & Multimedia Content

The Client Application can be a Web Browser,

a Mobile App, an IoT Device,

or another Service

Files

Databases

Back End Logic

Page 21: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Introducing AWS Lambda

Page 22: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Context

Function

Event AWS Lambda

Result

RequestResponse Function

Invocation

Lambda API Call

Synchronous Invocations

Page 23: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Context

Function

Event AWS Lambda

Event Function

Invocation

Lambda API Call

Asynchronous Invocations

Page 24: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

ContextContextResource

ContextContextResource

Context

Function

Event AWS Lambda Managed by AWS

Not managed by AWS

Result (Optional)

Function Invocation

Resources can be files, records

in a DB, etc.

Lambda API Call

Functions can Modify Resources

Page 25: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Events (Context)

Events (Context)

Generated by AWS

Not generated by AWS

ContextContextResource

ContextContextResource

Context

Function

Event AWS Lambda Managed by AWS

Not managed by AWS

Result (Optional)

Function Invocation

Lambda API Call

Resources can Generate more Events

Page 26: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Events (Context)

Events (Context)

Generated by AWS

Not generated by AWS

ContextContextResource

ContextContextResource

AWS Lambda Managed by AWS

Not managed by AWS

Direct Use of Resource

For example, a file is uploaded

or something is written in a database

AWS Lambda

Function 2

Function 3

Function 1

Events can Trigger more Functions

Page 27: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Sample Event-Driven Serverless Media-Sharing Application

Page 28: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

Event-driven Backend&

User

Page 29: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

Get Content Index

Get Content

Upload Content with Metadata

Update Content Metadata

Get Content Metadata

AWS Lambda

& User

Page 30: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

Get Content Index

Get Content

Upload Content with Metadata

Update Content Metadata

Get Content Metadata

Files (Multimedia)

Database

AWS Lambda

& User

Resources

Page 31: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

Get Content Index

Get Content and Thumbnails

Upload Content with Metadata

Update Content Metadata

Get Content Metadata

Files (Multimedia)

Database

Build Thumbnails

Update Content Index

Extract and Update Metadata

Event: new or

updated file

Event: new or updated

content metadata

AWS Lambda

& User

Resources

Page 32: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

Get Content Index

Get Content and Thumbnails

Upload Content with Metadata

Update Content Metadata

Get Content Metadata

Files (Multimedia)

Database

Build Thumbnails

Update Content Index

Extract and Update Metadata

Event: new or

updated file

Event: new or updated

content metadata

AWS Lambda

& User

Resources

Access to AWS services, such as AWS Lambda,

and the resources used by your application,

should be protected

Page 33: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Get Content Index

Get Content and Thumbnails

Upload Content with Metadata

Update Content Metadata

Get Content Metadata

Files (Multimedia)

Database

Build Thumbnails

Update Content Index

Extract and Update Metadata

& User

# Mobile

App

Page 34: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Get Content Index

Get Content and Thumbnails

Upload Content with Metadata

Update Content Metadata

Get Content Metadata

Files (Multimedia)

Database

Build Thumbnails

Update Content Index

Extract and Update Metadata

& User

" Web Browsers

(JavaScript)

Page 35: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Calling Lambda Function from the Client

Page 36: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

AWS Lambda Function

AWS Lambda Invoke API

& User

Calling Lambda Functions Directly

Page 37: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

AWS Lambda Function

AWS Lambda Invoke API

Get Temporary AWS Credentials Amazon

Cognito

& User

Getting AWS Credentials from Amazon Cognito

Page 38: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

AWS Lambda Function

Amazon Cognito

Amazon API Gateway

Get Temporary AWS Credentials

Web API Modeling, Caching, Throttling, Logging, CDN, etc.

& User

Exposing Functions as Web API

Page 39: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

AWS Lambda Function

Amazon API Gateway

Web API Modeling, Caching, Throttling, Logging, CDN, etc.

& User

Exposing Functions as Public Web API

Page 40: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

https://some.domain/stage/resource1/resource2/…/resourceN

GETPOSTPUTDELETEHEADPATCHOPTIONS

Unique domain that you can customize

API stage, for example prod, test, dev, or v0, v1, …

Resources as part of the URL

HTTP verb used when

accessing the URL

function1function2function3function1function2

function3function1

Function to execute

Web API to Lambda Functions Integration

Page 41: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Introducing Amazon Cognito Identity

Page 42: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

Amazon Cognito

1. Using the Application

2. Send Identity Pool ID

3. Get Identity ID + AWS Temp Credentials

for the Unauthenticated Role

All AWS Services, including

APIs managed by Amazon

API Gateway

AWS Services4. Call AWS Services using

AWS Temp Credentials& User

Amazon Cognito for Unauthenticated Identities

Page 43: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

Amazon Cognito

1. Using the Application

2. Send Identity Provider

Credentials

3. Get Authentication

Token4. Send

Identity Pool ID +Authentication Token

6. Get Identity ID + AWS Temp Credentials

for the Authenticated Role

All AWS Services, including

APIs managed by Amazon

API Gateway

AWS Services7. Call AWS Services using

AWS Temp Credentials

5. CheckAuthentication Tokenwith Identity Provider

Identity Provider

& User

Amazon Cognito for Authenticated Identities

Page 44: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Client Application

Custom Authentication Amazon

Cognito

1. Using the Application

2. Send Identity Provider

Credentials

4. Send Authentication

Token to Client 5. Send

Identity Pool ID +Authentication Token

6. Get Identity ID + AWS Temp Credentials

for the Authenticated Role

All AWS Services, including

APIs managed by Amazon

API Gateway

AWS Services7. Call AWS Services using

AWS Temp Credentials

3. Get Authentication

Token from Cognito

& User

Amazon Cognito for Developer Authenticated Identities

Page 45: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Best Practices

Page 46: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

!

Reactive Manifesto

Page 47: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

!

Reactive Manifesto

Page 48: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Reactive Manifesto

DistributedAsynchronous

Eventual Consistency

!

Page 49: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

<demo>…

</demo>

Page 50: Event-Driven Serverless Apps - Pop-up Loft Tel Aviv

Danilo  PocciaTechnical  Evangelist          @danilop