SlideShare a Scribd company logo
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Chris Munns – Senior Developer Advocate – AWS
Serverless
How to Build Applications
with MongoDB Atlas and AWS
Lambda
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
About me:
Chris Munns - munns@amazon.com, @chrismunns
• Senior Developer Advocate - Serverless
• New Yorker
• Previously:
• AWS Business Development Manager – DevOps, July ’15 - Feb ‘17
• AWS Solutions Architect Nov, 2011- Dec 2014
• Formerly on operations teams @Etsy and @Meetup
• Little time at a hedge fund, Xerox and a few other startups
• Rochester Institute of Technology: Applied Networking and Systems
Administration ’05
• Internet infrastructure geek
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
https://secure.flickr.com/photos/mgifford/4525333972
Why are we
here today?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
No servers to provision
or manage
Scales with usage
Never pay for idle Availability and fault
tolerance built in
Serverless means…
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SERVICES (ANYTHING)
Changes in
data state
Requests to
endpoints
Changes in
resource state
EVENT SOURCE FUNCTION
Node.js
Python
Java
C#
Go
Serverless applications
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Anatomy of a Lambda function
Handler() function
Function to be executed
upon invocation
Event object
Data sent during
Lambda Function
Invocation
Context object
Methods available to
interact with runtime
information (request ID,
log group, etc.)
public String handleRequest(Book book, Context context) {
saveBook(book);
return book.getName() + " saved!";
}
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using AWS Lambda
Bring your own code
• Node.js, Java, Python,
C#, Go
• Bring your own libraries
(even native ones)
Simple resource model
• Select power rating from
128 MB to 3 GB
• CPU and network
allocated proportionately
Flexible use
• Synchronous or
asynchronous
• Integrated with other
AWS services
Flexible authorization
• Securely grant access to
resources and VPCs
• Fine-grained control for
invoking your functions
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using AWS Lambda
Authoring functions
• Cloud9
• WYSIWYG editor or
upload packaged .zip
• Third-party plugins
(Eclipse, Visual Studio)
Monitoring and logging
• Metrics for requests,
errors, and throttles
• Built-in logs to Amazon
CloudWatch Logs
• X-Ray integration
Programming model
• Use processes, threads,
/tmp, sockets normally
• AWS SDK built in
(Python and Node.js)
Stateless
• Persist data using
external storage
• No affinity or access to
underlying infrastructure
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Common Lambda use cases
Web
Applications
• Static
websites
• Complex web
apps
• Packages for
Flask and
Express
Data
Processing
• Real time
• MapReduce
• Batch
Chatbots
• Powering
chatbot logic
Backends
• Apps &
services
• Mobile
• IoT
</></>
Amazon
Alexa
• Powering
voice-enabled
apps
• Alexa Skills
Kit
IT
Automation
• Policy engines
• Extending
AWS services
• Infrastructure
management
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Create a unified
API frontend for
multiple micro-
services
Authenticate and
authorize
requests to a
backend
DDoS protection
and throttling for
your backend
Throttle, meter,
and monetize API
usage by 3rd
party developers
Amazon API Gateway
API Gateway integrations
Internet
Mobile Apps
Websites
Services
AWS Lambda
functions
AWS
API Gateway
Cache
Endpoints on
Amazon EC2
Amazon
CloudWatch
Monitoring
Amazon
CloudFront
Any other AWS
service
YOUR VPC
Endpoints in
Your VPC
Regional API Endpoints
All publicly accessible
endpoints
AWS Lambda
functions
Amazon Kinesis + Lambda
Amazon
Kinesis
AWS
Lambda 1
Amazon
CloudWatch
Amazon
DynamoDB
AWS
Lambda 2 Amazon
S3
Real Time Data Processing:
1. Real-time event data sent to Amazon Kinesis,
allows multiple AWS Lambda functions to
process the same events.
2. In AWS Lambda, Function 1 processes and
aggregates data from incoming events, then
stores result data in Amazon DynamoDB
3. Lambda Function 1 also sends values to
Amazon CloudWatch for simple monitoring of
metrics.
4. In AWS Lambda function, Function 2 does data
manipulation of incoming events and stores
results in Amazon S3
https://s3.amazonaws.com/awslambda-reference-architectures/stream-processing/lambda-refarch-streamprocessing.pdf
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What is MongoDB Atlas?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MongoDB Atlas
Deploy, operate, and scale a MongoDB database in
the cloud with just a few clicks.
• Self Service & Elastic
• Global and highly available
• Secure by default
• Comprehensive Monitoring
• Managed Backup
• Multi-region and Multi-cloud
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MongoDB Atlas - Capabilities
Fine grained monitoring
and alerts
Consolidated database
management
Real-time performance
panel
Performance Advisor Data Explorer Query-able backup
snapshots
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Why DBaaS?
On-premises Database as a ServiceSelf-managed in the cloud
Hardware procurement
Install / rack servers
Configure Network
Audit data center / update inventory
Install operating system
Harden Security configuration
Install Database
Configure Database
Load Data
Test/Validate Configuration
Build a private network in the cloud
Set up security groups
Research and test instance types
to run the database
Configure for high availability
Launch instances
Install MongoDB automation agent
Configure SSL / TLS
Choose instance, hit “deploy”,
wait a few minutes
Time to Value: Weeks to Months
Complex Coordination
Time to Value: Hours to Days
Complex Coordination
Time to Value: Minutes
Entirely self-service
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Secure your API
https://www.flickr.com/photos/modernrelics/1093797721/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API Gateway Security
Several mechanisms for adding Authz/Authn to our API:
• IAM Permissions
• Use IAM policies and AWS credentials to grant access
• Custom Authorizers
• Use Lambda to validate a bearer token(Oauth or SAML as
examples) or request parameters and grant access
• Cognito User Pools
• Create a completely managed user management system
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Authentication type comparison
Feature AWS_IAM TOKEN REQUEST COGNITO
Authentication X X X X
Authorization X X X
SignatureV4 X
Cognito User Pools X X X
Third-Party
Authentication
X X
Multiple Header Support X
Additional Costs NONE Pay per
authorizer
invoke
Pay per authorizer
invoke
NONE
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Cognito User Pools
Add user sign-up and sign-
in easily to your mobile and
web apps without worrying
about server infrastructure
Serverless Authentication
and User Management
Verify phone numbers and
email addresses and offer
multi-factor authentication
Enhanced Security
Features
Launch a simple, secure,
low-cost, and fully managed
service to create and
maintain a user directory
that scales to 100s of
millions of users
Managed User Directory
1 2 3
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Where do you ..
https://secure.flickr.com/photos/stevendepolo/5749192025/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
InternetMobile/Web
apps
AWS Lambda
functions
AWS
API Gateway
Basic API technology stack
MongoDB
Atlas
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Meet
SAM!
AWS Serverless Application Model (SAM)
CloudFormation extension optimized for
serverless
New serverless resource types: functions, APIs,
and tables
Supports anything CloudFormation supports
Open specification (Apache 2.0)
- SAM Translator recently open sourced!
https://github.com/awslabs/serverless-application-model
SAM Template
AWSTemplateFormatVersion: '2010-09-09’
Transform: AWS::Serverless-2016-10-31
Resources:
GetHtmlFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/todo_list.zip
Handler: index.gethtml
Runtime: nodejs4.3
Policies: AmazonDynamoDBReadOnlyAccess
Events:
GetHtml:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
ListTable:
Type: AWS::Serverless::SimpleTable
SAM Template
Tells CloudFormation this is a SAM
template it needs to “transform”
Creates a Lambda function with the
referenced managed IAM policy,
runtime, code at the referenced zip
location, and handler as defined.
Also creates an API Gateway and
takes care of all
mapping/permissions necessary
Creates a DynamoDB table with 5
Read & Write units
AWSTemplateFormatVersion: '2010-09-09’
Transform: AWS::Serverless-2016-10-31
Resources:
GetHtmlFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/todo_list.zip
Handler: index.gethtml
Runtime: nodejs4.3
Policies: AmazonDynamoDBReadOnlyAccess
Events:
GetHtml:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
ListTable:
Type: AWS::Serverless::SimpleTable
From: https://github.com/awslabs/aws-serverless-samfarm/blob/master/api/saml.yaml
<-THIS
BECOMES THIS->
SAM Template
AWS SAM CLI SAM Local
Relaunched/GA’d on May 8th!
CLI tool for local building, validating, testing of
serverless apps
Works with Lambda functions and “proxy-style”
APIs
Response object and function logs available on
your local machine
Uses open source docker-lambda images to mimic
Lambda’s execution environment:
• Emulates timeout, memory limits, runtimes
https://github.com/awslabs/aws-sam-cli
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Cloud9
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Today’s Lab:
• Generate data into Kinesis via:
https://github.com/awslabs/amazon-kinesis-data-generator
• Lambda digests Kinesis stream and puts into MongoDB Atlas
• Web front end -> API GW -> Lambda -> MongoDB to view data.
• Cloud9 to deploy AWS resources.
• Minimal Pre-requisties – Atlas account, AWS account, browser
• Use either Cloud9 or local laptop w/ AWS CLI, SAM CLI, and
an editor
• You will need administrative privileges on your AWS account
for this
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
InternetMobile/Web
apps
AWS Lambda
functions
AWS
API Gateway
Today’s Lab:
MongoDB
Atlas
Amazon
Kinesis
AWS Lambda
functions
Kinesis Generator AtlasVPC
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
InternetMobile/Web
apps
AWS Lambda
functions
AWS
API Gateway
Today’s Lab:
MongoDB
Atlas
Amazon
Kinesis
AWS Lambda
functions
Kinesis Generator AtlasVPC
Deployed
via Atlas
Dashboard
Ingest App Deployed via
SAM
Browser
based
app
hosted in
S3
WebApp API Deployed
via SAM
Lab!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Chris Munns
munns@amazon.com
@chrismunnshttps://www.flickr.com/photos/theredproject/3302110152/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
?
https://secure.flickr.com/photos/dullhunk/202872717/

More Related Content

PDF
Modern Applications Web Day | Impress Your Friends with Your First Serverless...
PDF
20200520 - Como empezar a desarrollar aplicaciones serverless
PDF
Wildrydes Serverless Workshop Tel Aviv
PDF
Building Serverless Microservices with AWS
PDF
Infinite Scaling using Lambda and Aws - Atlogys Tech Talk
PDF
Introduction to Serverless Computing and AWS Lambda - AWS IL Meetup
PDF
Building serverless backends - Tech talk 5 May 2017
PDF
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Modern Applications Web Day | Impress Your Friends with Your First Serverless...
20200520 - Como empezar a desarrollar aplicaciones serverless
Wildrydes Serverless Workshop Tel Aviv
Building Serverless Microservices with AWS
Infinite Scaling using Lambda and Aws - Atlogys Tech Talk
Introduction to Serverless Computing and AWS Lambda - AWS IL Meetup
Building serverless backends - Tech talk 5 May 2017
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway

Similar to MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas & AWS Lambda (20)

PPTX
DevOps, Microservices and Serverless Architecture
PDF
Serverless applications with AWS
PDF
Scaling your Mobile App Development in the Cloud - DevNexus
PDF
2016-06 - Design your api management strategy - AWS - Microservices on AWS
PDF
Getting Started with AWS Lambda & Serverless Cloud
PPTX
Getting started with Serverless on AWS
PDF
Jumpstart your idea with AWS Serverless [Oct 2020]
PPTX
Serverless Developer Experience I AWS Dev Day 2018
PDF
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
PDF
Voxxed Athens 2018 - Serverless by Design
PPTX
Reply Labcamp Rome - AWS Zombie - Serverless and Microservices
PPTX
AWS Accelerated Program - Session 3 - Serverless Services.pptx
PDF
Como construir suas aplicações escaláveis sem servidores
PPTX
Building API Driven Microservices
PDF
Build a mobile app serverless with AWS Lambda
PDF
Introducing to serverless computing and AWS lambda - Israel Clouds Meetup
PDF
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
PDF
Getting Started with AWS Lambda and Serverless Computing
PDF
Build an app on aws for your first 10 million users (2)
PPTX
Going Serverless at AWS Startup Day Bangalore
DevOps, Microservices and Serverless Architecture
Serverless applications with AWS
Scaling your Mobile App Development in the Cloud - DevNexus
2016-06 - Design your api management strategy - AWS - Microservices on AWS
Getting Started with AWS Lambda & Serverless Cloud
Getting started with Serverless on AWS
Jumpstart your idea with AWS Serverless [Oct 2020]
Serverless Developer Experience I AWS Dev Day 2018
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Voxxed Athens 2018 - Serverless by Design
Reply Labcamp Rome - AWS Zombie - Serverless and Microservices
AWS Accelerated Program - Session 3 - Serverless Services.pptx
Como construir suas aplicações escaláveis sem servidores
Building API Driven Microservices
Build a mobile app serverless with AWS Lambda
Introducing to serverless computing and AWS lambda - Israel Clouds Meetup
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
Getting Started with AWS Lambda and Serverless Computing
Build an app on aws for your first 10 million users (2)
Going Serverless at AWS Startup Day Bangalore
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
Ad

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
KodekX | Application Modernization Development
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Cloud computing and distributed systems.
PPTX
A Presentation on Artificial Intelligence
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Electronic commerce courselecture one. Pdf
PDF
Modernizing your data center with Dell and AMD
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Network Security Unit 5.pdf for BCA BBA.
Encapsulation theory and applications.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25 Week I
Cloud computing and distributed systems.
A Presentation on Artificial Intelligence
MYSQL Presentation for SQL database connectivity
Electronic commerce courselecture one. Pdf
Modernizing your data center with Dell and AMD
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Understanding_Digital_Forensics_Presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Chapter 3 Spatial Domain Image Processing.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Network Security Unit 5.pdf for BCA BBA.

MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas & AWS Lambda

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Chris Munns – Senior Developer Advocate – AWS Serverless How to Build Applications with MongoDB Atlas and AWS Lambda
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. About me: Chris Munns - munns@amazon.com, @chrismunns • Senior Developer Advocate - Serverless • New Yorker • Previously: • AWS Business Development Manager – DevOps, July ’15 - Feb ‘17 • AWS Solutions Architect Nov, 2011- Dec 2014 • Formerly on operations teams @Etsy and @Meetup • Little time at a hedge fund, Xerox and a few other startups • Rochester Institute of Technology: Applied Networking and Systems Administration ’05 • Internet infrastructure geek
  • 3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. https://secure.flickr.com/photos/mgifford/4525333972 Why are we here today?
  • 4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. No servers to provision or manage Scales with usage Never pay for idle Availability and fault tolerance built in Serverless means…
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state EVENT SOURCE FUNCTION Node.js Python Java C# Go Serverless applications
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Anatomy of a Lambda function Handler() function Function to be executed upon invocation Event object Data sent during Lambda Function Invocation Context object Methods available to interact with runtime information (request ID, log group, etc.) public String handleRequest(Book book, Context context) { saveBook(book); return book.getName() + " saved!"; }
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using AWS Lambda Bring your own code • Node.js, Java, Python, C#, Go • Bring your own libraries (even native ones) Simple resource model • Select power rating from 128 MB to 3 GB • CPU and network allocated proportionately Flexible use • Synchronous or asynchronous • Integrated with other AWS services Flexible authorization • Securely grant access to resources and VPCs • Fine-grained control for invoking your functions
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using AWS Lambda Authoring functions • Cloud9 • WYSIWYG editor or upload packaged .zip • Third-party plugins (Eclipse, Visual Studio) Monitoring and logging • Metrics for requests, errors, and throttles • Built-in logs to Amazon CloudWatch Logs • X-Ray integration Programming model • Use processes, threads, /tmp, sockets normally • AWS SDK built in (Python and Node.js) Stateless • Persist data using external storage • No affinity or access to underlying infrastructure
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Common Lambda use cases Web Applications • Static websites • Complex web apps • Packages for Flask and Express Data Processing • Real time • MapReduce • Batch Chatbots • Powering chatbot logic Backends • Apps & services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit IT Automation • Policy engines • Extending AWS services • Infrastructure management
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Create a unified API frontend for multiple micro- services Authenticate and authorize requests to a backend DDoS protection and throttling for your backend Throttle, meter, and monetize API usage by 3rd party developers Amazon API Gateway
  • 11. API Gateway integrations Internet Mobile Apps Websites Services AWS Lambda functions AWS API Gateway Cache Endpoints on Amazon EC2 Amazon CloudWatch Monitoring Amazon CloudFront Any other AWS service YOUR VPC Endpoints in Your VPC Regional API Endpoints All publicly accessible endpoints AWS Lambda functions
  • 12. Amazon Kinesis + Lambda Amazon Kinesis AWS Lambda 1 Amazon CloudWatch Amazon DynamoDB AWS Lambda 2 Amazon S3 Real Time Data Processing: 1. Real-time event data sent to Amazon Kinesis, allows multiple AWS Lambda functions to process the same events. 2. In AWS Lambda, Function 1 processes and aggregates data from incoming events, then stores result data in Amazon DynamoDB 3. Lambda Function 1 also sends values to Amazon CloudWatch for simple monitoring of metrics. 4. In AWS Lambda function, Function 2 does data manipulation of incoming events and stores results in Amazon S3 https://s3.amazonaws.com/awslambda-reference-architectures/stream-processing/lambda-refarch-streamprocessing.pdf
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What is MongoDB Atlas?
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MongoDB Atlas Deploy, operate, and scale a MongoDB database in the cloud with just a few clicks. • Self Service & Elastic • Global and highly available • Secure by default • Comprehensive Monitoring • Managed Backup • Multi-region and Multi-cloud
  • 15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MongoDB Atlas - Capabilities Fine grained monitoring and alerts Consolidated database management Real-time performance panel Performance Advisor Data Explorer Query-able backup snapshots
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Why DBaaS? On-premises Database as a ServiceSelf-managed in the cloud Hardware procurement Install / rack servers Configure Network Audit data center / update inventory Install operating system Harden Security configuration Install Database Configure Database Load Data Test/Validate Configuration Build a private network in the cloud Set up security groups Research and test instance types to run the database Configure for high availability Launch instances Install MongoDB automation agent Configure SSL / TLS Choose instance, hit “deploy”, wait a few minutes Time to Value: Weeks to Months Complex Coordination Time to Value: Hours to Days Complex Coordination Time to Value: Minutes Entirely self-service
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Secure your API https://www.flickr.com/photos/modernrelics/1093797721/
  • 18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway Security Several mechanisms for adding Authz/Authn to our API: • IAM Permissions • Use IAM policies and AWS credentials to grant access • Custom Authorizers • Use Lambda to validate a bearer token(Oauth or SAML as examples) or request parameters and grant access • Cognito User Pools • Create a completely managed user management system
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Authentication type comparison Feature AWS_IAM TOKEN REQUEST COGNITO Authentication X X X X Authorization X X X SignatureV4 X Cognito User Pools X X X Third-Party Authentication X X Multiple Header Support X Additional Costs NONE Pay per authorizer invoke Pay per authorizer invoke NONE
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cognito User Pools Add user sign-up and sign- in easily to your mobile and web apps without worrying about server infrastructure Serverless Authentication and User Management Verify phone numbers and email addresses and offer multi-factor authentication Enhanced Security Features Launch a simple, secure, low-cost, and fully managed service to create and maintain a user directory that scales to 100s of millions of users Managed User Directory 1 2 3
  • 21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Where do you .. https://secure.flickr.com/photos/stevendepolo/5749192025/
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. InternetMobile/Web apps AWS Lambda functions AWS API Gateway Basic API technology stack MongoDB Atlas
  • 23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Meet SAM!
  • 24. AWS Serverless Application Model (SAM) CloudFormation extension optimized for serverless New serverless resource types: functions, APIs, and tables Supports anything CloudFormation supports Open specification (Apache 2.0) - SAM Translator recently open sourced! https://github.com/awslabs/serverless-application-model
  • 25. SAM Template AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetHtmlFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip Handler: index.gethtml Runtime: nodejs4.3 Policies: AmazonDynamoDBReadOnlyAccess Events: GetHtml: Type: Api Properties: Path: /{proxy+} Method: ANY ListTable: Type: AWS::Serverless::SimpleTable
  • 26. SAM Template Tells CloudFormation this is a SAM template it needs to “transform” Creates a Lambda function with the referenced managed IAM policy, runtime, code at the referenced zip location, and handler as defined. Also creates an API Gateway and takes care of all mapping/permissions necessary Creates a DynamoDB table with 5 Read & Write units AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetHtmlFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip Handler: index.gethtml Runtime: nodejs4.3 Policies: AmazonDynamoDBReadOnlyAccess Events: GetHtml: Type: Api Properties: Path: /{proxy+} Method: ANY ListTable: Type: AWS::Serverless::SimpleTable
  • 28. AWS SAM CLI SAM Local Relaunched/GA’d on May 8th! CLI tool for local building, validating, testing of serverless apps Works with Lambda functions and “proxy-style” APIs Response object and function logs available on your local machine Uses open source docker-lambda images to mimic Lambda’s execution environment: • Emulates timeout, memory limits, runtimes https://github.com/awslabs/aws-sam-cli
  • 29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Cloud9
  • 30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Today’s Lab: • Generate data into Kinesis via: https://github.com/awslabs/amazon-kinesis-data-generator • Lambda digests Kinesis stream and puts into MongoDB Atlas • Web front end -> API GW -> Lambda -> MongoDB to view data. • Cloud9 to deploy AWS resources. • Minimal Pre-requisties – Atlas account, AWS account, browser • Use either Cloud9 or local laptop w/ AWS CLI, SAM CLI, and an editor • You will need administrative privileges on your AWS account for this
  • 31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. InternetMobile/Web apps AWS Lambda functions AWS API Gateway Today’s Lab: MongoDB Atlas Amazon Kinesis AWS Lambda functions Kinesis Generator AtlasVPC
  • 32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. InternetMobile/Web apps AWS Lambda functions AWS API Gateway Today’s Lab: MongoDB Atlas Amazon Kinesis AWS Lambda functions Kinesis Generator AtlasVPC Deployed via Atlas Dashboard Ingest App Deployed via SAM Browser based app hosted in S3 WebApp API Deployed via SAM
  • 33. Lab!
  • 34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Chris Munns munns@amazon.com @chrismunnshttps://www.flickr.com/photos/theredproject/3302110152/
  • 35. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ? https://secure.flickr.com/photos/dullhunk/202872717/