View
311
Download
2
Category
Preview:
Citation preview
Event-‐Driven Serverless AppsDanilo Poccia, Technical Evangelist
@danilop
Event-Driven in the Front End
Name
Create New User
Submit
Check the “Name” syntax is right (only letters and spaces)
Check the “Email” syntax is right (something@some.domain)
Create the new user using provided Name and Email
User Interface Actions
Name
Create New User
Submit
Check the “Name” syntax is right (only letters and spaces)
Check the “Email” syntax is right (something@some.domain)
Create the new user using provided Name and Email
User Interface ActionsObservers
Target Action
What about the Back End ?
! Users
Internet
! Users
Back End Logic
Internet
! Users
Back End Data
Back End Logic
Internet
! Users
Back End Data
Application Back End
Back End Logic
Internet
! Users
Application Back End" Web Browsers
Back End Data
Back End Logic
Application Back End" Web Browsers
# Mobile Apps Back End
Data
Back End Logic
Application Back End" Web Browsers
# Mobile Apps
$ IoT Devices
Back End Data
Back End Logic
Application Back End" Web Browsers
# Mobile Apps
$ IoT Devices
% Other Services
Back End Data
Back End Logic
Application Back End
Files
Databases
" Web Browsers
# Mobile Apps
$ IoT Devices
% Other Services
Back End Logic
HTML, CSS, JavaScript & Multimedia Content
API Calls
Application Back End" Web Browsers
# Mobile Apps
$ IoT Devices
% Other Services
Files
Databases
Back End Logic
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
API Calls
Application Back End
HTML, CSS, JavaScript & Multimedia Content
" Web Browsers
(JavaScript)
# Mobile Apps
$ IoT Devices
% Other Services
Files
Databases
Back End Logic
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
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
Introducing AWS Lambda
Context
Function
Event AWS Lambda
Result
RequestResponse Function
Invocation
Lambda API Call
Synchronous Invocations
Context
Function
Event AWS Lambda
Event Function
Invocation
Lambda API Call
Asynchronous Invocations
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
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
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
Sample Event-Driven Serverless Media-Sharing Application
Client Application
Event-driven Backend&
User
Client Application
Get Content Index
Get Content
Upload Content with Metadata
Update Content Metadata
Get Content Metadata
AWS Lambda
& User
Client Application
Get Content Index
Get Content
Upload Content with Metadata
Update Content Metadata
Get Content Metadata
Files (Multimedia)
Database
AWS Lambda
& User
Resources
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
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
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
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)
Calling Lambda Function from the Client
Client Application
AWS Lambda Function
AWS Lambda Invoke API
& User
Calling Lambda Functions Directly
Client Application
AWS Lambda Function
AWS Lambda Invoke API
Get Temporary AWS Credentials Amazon
Cognito
& User
Getting AWS Credentials from Amazon Cognito
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
Client Application
AWS Lambda Function
Amazon API Gateway
Web API Modeling, Caching, Throttling, Logging, CDN, etc.
& User
Exposing Functions as Public Web API
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
Introducing Amazon Cognito Identity
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
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
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
Best Practices
!
Reactive Manifesto
!
Reactive Manifesto
Reactive Manifesto
DistributedAsynchronous
Eventual Consistency
!
<demo>…
</demo>
Danilo PocciaTechnical Evangelist @danilop
Recommended