SlideShare a Scribd company logo
©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved
Building serverless APIs
Julien Simon, Principal Technical Evangelist, AWS
julsimon@amazon.fr 
@julsimon
Serverless
architecture"
="
Managed services "
+"
AWS Lambda"
"
Reference architectures: http://www.allthingsdistributed.com/2016/06/aws-lambda-serverless-reference-architectures.html
AWS Lambda
•  Announced at re:Invent 2014
•  Deploy pure functions in Java, Python, Node.js and C#
•  Just code, without the infrastructure drama
•  Built-in scalability and high availability
•  Integrated with many AWS services
•  Pay as you go
•  Combination of execution time (100ms slots) & memory used
•  Starts at $0.000000208 per 100ms
•  Free tier available: first 1 million requests per month are free
http://aws.amazon.com/lambda 
AWS re:Invent 2014 | (MBL202) NEW LAUNCH: Getting Started with AWS Lambda https://www.youtube.com/watch?v=UFj27laTWQA
What can you do with AWS Lambda?
•  Grow ‘connective tissue’ in your AWS infrastructure
–  Example: http://www.slideshare.net/JulienSIMON5/building-a-serverless-pipeline 

•  Build event-driven applications
•  Build APIs together with Amazon API Gateway
•  RESTful APIs
•  Resources, methods
•  Stages
http://aws.amazon.com/apigateway
https://read.acloud.guru/serverless-the-future-of-software-architecture-d4473ffed864 
A Cloud Guru: 100% Serverless
Typical development workflow
1.  Write and deploy a Lambda function
2.  Create and deploy a REST API with API Gateway
3.  Connect the API to the Lambda function
4.  Invoke the API
5.  Test, debug and repeat ;)
"
Simplifying Development "
"Code samples available at https://github.com/juliensimon/aws/tree/master/lambda_frameworks "
"
The Serverless framework "
formerly known as JAWS: Just AWS Without Servers


•  Announced at re:Invent 2015 by Austen Collins and Ryan Pendergast
•  Supports Node.js, as well as Python and Java (with restrictions) 
•  Auto-deploys and runs Lambda functions, locally or remotely

•  Auto-deploys your Lambda event sources: API Gateway, S3, DynamoDB, etc.
•  Creates all required infrastructure with CloudFormation
•  Simple configuration in YML

http://github.com/serverless/serverless 
https://serverless.com 
AWS re:Invent 2015 | (DVO209) https://www.youtube.com/watch?v=D_U6luQ6I90 & https://vimeo.com/141132756
Serverless: “Hello World” API
$ serverless create
Edit handler.js, serverless.yml and event.json
$ serverless deploy [--stage stage_name]
$ serverless invoke [--local] --function function_name
$ serverless info
$ http $URL
Gordon
•  Released in Oct’15 by Jorge Batista
•  Supports Python, Javascript, Golang, Java, Scala, Kotlin (including in the same project)
•  Auto-deploys and runs Lambda functions, locally or remotely

•  Auto-deploys your Lambda event sources: API Gateway, CloudWatch Events, DynamoDB
Streams, Kinesis Streams, S3
•  Creates all required infrastructure with CloudFormation

•  Simple configuration in YML
https://github.com/jorgebastida/gordon 
https://news.ycombinator.com/item?id=11821295
Gordon: “Hello World” API
$ gordon startproject helloworld
$ gordon startapp helloapp
Write hellofunc() function
$ gordon build
$ echo '{"name":"Julien"}' | gordon run helloapp.hellofunc
$ gordon apply [--stage stage_name]
$ http post $URL name=Julien
AWS Chalice "
Think of it as a serverless framework for Flask apps"

•  Released in Jul’16, still in beta
•  Just add your Python code
–  Deploy with a single call and zero config
–  The API is created automatically, the IAM policy is auto-generated
•  Run APIs locally on port 8000 (similar to Flask)
•  Fast & lightweight framework
–  100% boto3 calls (AWS SDK for Python) à fast
–  No integration with CloudFormation à no creation of event sources
https://github.com/awslabs/chalice 
https://aws.amazon.com/blogs/developer/preview-the-python-serverless-microframework-for-aws/
AWS Chalice: “Hello World” API
$ chalice new-project helloworld
Write your function in app.py
$ chalice local
$ chalice deploy
$ export URL=`chalice url`
$ http $URL
$ http put $URL/hello/julien
$ chalice logs [ --include-lambda-messages ]
AWS Chalice: PUT/GET in S3 bucket
$ chalice new-project s3test
Write your function in app.py
$ chalice local
$ http put http://localhost:8000/objects/doc.json value1=5 value2=8
$ http get http://localhost:8000/objects/doc.json
$ chalice deploy [stage_name]
$ export URL=`chalice url`
$ http put $URL/objects/doc.json value1=5 value2=8
$ http get $URL/objects/doc.json
Summing things up
Serverless

The most popular
serverless framework

Built with and for Node.js.
Python and Java: YMMV

Rich features, many event
sources

Not a web framework
Gordon

Great challenger!

Node.js, Python, Java,
Scala, Golang

Comparable to Serverless
feature-wise

Not a web framework



Chalice

AWS project, in beta

Python only

Does only one thing, but
does it great

Dead simple, zero config

Flask web framework
More Lambda frameworks
•  Kappa https://github.com/garnaat/kappa 
–  Released Dec’14 by Mitch Garnaat, author of boto and the AWS CLI (still maintained?)
–  Python only, multiple event sources
•  Apex https://github.com/apex/apex 
–  Released in Dec’15 by TJ Holowaychuk
–  Python, Javascript, Java, Golang
–  Terraform integration to manage infrastructure for event sources
•  Zappa https://github.com/Miserlou/Zappa 
–  Released in Feb’16 by Rich Jones
–  Python web applications on AWS Lambda + API Gateway
•  Docker-lambda https://github.com/lambci/docker-lambda 
–  Released in May’16 by Michael Hart
–  Run functions in Docker images that “replicate” the live Lambda environment
2 Java tools for AWS Lambda













https://java.awsblog.com/post/TxWZES6J1RSQ2Z/Testing-Lambda-functions-using-the-AWS-Toolkit-for-Eclipse 
https://aws.amazon.com/blogs/developer/aws-toolkit-for-eclipse-serverless-application
https://github.com/awslabs/aws-serverless-java-container 
Eclipse plug-in

•  Code, test and deploy Lambdas from Eclipse
•  Run your functions locally and remotely
•  Test with local events and Junit4 
•  Deploy standalone functions, or with the "
AWS Serverless Application Model (Dec’16)
Serverless Java Container

•  Run Java RESTful APIs as-is
•  Default implementation of the
Java servlet
HttpServletRequest "
HttpServletResponse
•  Support for Java frameworks
such as Jersey or Spark
"
"
Simplifying Deployment"
AWS Serverless Application Model (SAM)"

•  CloudFormation extension released in Nov’16 to bundle
Lambda functions, APIs & events
•  3 new CloudFormation resource types
–  AWS::Serverless::Function
–  AWS::Serverless::Api
–  AWS::Serverless::SimpleTable (DynamoDB)
•  2 new CloudFormation CLI commands
–  ‘aws cloudformation package’
–  ‘aws cloudformation deploy’
•  Integration with CodeBuild and CodePipeline for CI/CD
•  Expect SAM to be integrated in most / all frameworks
https://aws.amazon.com/fr/blogs/compute/introducing-simplified-serverless-application-deplyoment-and-management 
https://github.com/awslabs/serverless-application-model/
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Get items from a DynamoDB table.
Resources:
GetFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.get
Runtime: nodejs4.3
Policies: AmazonDynamoDBReadOnlyAccess
Environment:
Variables:
TABLE_NAME: !Ref Table
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Method: get
Table:
Type: AWS::Serverless::SimpleTable

Sample SAM template for:

•  Lambda function
•  HTTP GET API
•  DynamoDB table
"
"
Lambda@Edge"
preview
The AWS edge
North America
 South America
 EMEA
 APAC
POPs
Cities
 Countries
 Continents
Regional Edge Caches
Lambda@Edge
•  Lambda@Edge is an extension of AWS Lambda that allows you to run
Node.js code at AWS global edge locations.
•  Bring your own code to the edge and customize your content very
close to your users, improving the end-user experience.
•  Typical use cases
•  Customize content, based on user/device properties
•  Validate visitors: check tokens, filter bot traffic
•  Rewrite URLs: inject ads, hide file structure 
•  Run A/B testing
CloudFront Triggers for "
Lambda@Edge Functions
Lambda@Edge Service Limits
Items Lambda@Edge Lambda
Timeout 50 ms 300 seconds
Function “Power Level” 128 MB 128 MB – 1.5 GB
Function Deployment
Package Size
1MB 50MB
•  Runtime: Node.js 4.3
•  Triggered by CloudFront events
•  Access: No network connections, AWS region access, disk
access or Amazon VPC
Lambda@Edge demo: the Metal A/B test m/
•  Static website in S3, distributed to CloudFront
http://d2eb9d90qk3238.cloudfront.net
•  The index page references an image file that
doesn’t exist in the S3 bucket
<img src="http://d2eb9d90qk3238.cloudfront.net/album.jpg">

•  A Lambda function is triggered on the “Origin
request” event and replaces album.jpg with a
random file
"
"
Going further"
New Lambda videos from re:Invent 2016
AWS re:Invent 2016: What’s New with AWS Lambda (SVR202)
https://www.youtube.com/watch?v=CwxWhyGteNc 

AWS re:Invent 2016: Serverless Apps with AWS Step Functions (SVR201)
https://www.youtube.com/watch?v=75MRve4nv8s 

AWS re:Invent 2016: Real-time Data Processing Using AWS Lambda (SVR301)
https://www.youtube.com/watch?v=VFLKOy4GKXQ 

AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC402)
https://www.youtube.com/watch?v=b7UMoc1iUYw 

‪AWS re:Invent 2016: Bringing AWS Lambda to the Edge (CTD206)‬
https://www.youtube.com/watch?v=j26novaqF6M 

‪AWS re:Invent 2016: Ubiquitous Computing with Greengrass (IOT201)‬
https://www.youtube.com/watch?v=XQQjX8GTEko
The only Lambda book you need to read
Written by AWS Technical
Evangelist Danilo Poccia

Released in December 2016

https://www.amazon.com/Aws-Lambda-Action-
Event-driven-Applications/dp/1617293717/
Thank you!"
	
Julien	Simon,	Principal	Technical	Evangelist,	AWS	
julsimon@amazon.fr	
@julsimon

More Related Content

PDF
Building Serverless APIs on AWS
PDF
Building serverless apps with Node.js
PDF
Developing and deploying serverless applications (February 2017)
PDF
Continuous Deployment with Amazon Web Services
PDF
An introduction to serverless architectures (February 2017)
PDF
Infrastructure as code with Amazon Web Services
PDF
Serverless Frameworks on AWS
PDF
DevOps with Amazon Web Services (November 2016)
Building Serverless APIs on AWS
Building serverless apps with Node.js
Developing and deploying serverless applications (February 2017)
Continuous Deployment with Amazon Web Services
An introduction to serverless architectures (February 2017)
Infrastructure as code with Amazon Web Services
Serverless Frameworks on AWS
DevOps with Amazon Web Services (November 2016)

What's hot (9)

PDF
Running Open Source Platforms on AWS (November 2016)
PDF
Building a Serverless Pipeline
PDF
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
PDF
Deep Dive: Amazon Relational Database Service (March 2017)
PDF
A 60-minute tour of AWS Compute (November 2016)
PDF
Running Docker clusters on AWS (November 2016)
PDF
An Overview of AWS IoT (November 2016)
PDF
AWS CloudFormation (February 2016)
PDF
Devops with Amazon Web Services (January 2017)
Running Open Source Platforms on AWS (November 2016)
Building a Serverless Pipeline
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
Deep Dive: Amazon Relational Database Service (March 2017)
A 60-minute tour of AWS Compute (November 2016)
Running Docker clusters on AWS (November 2016)
An Overview of AWS IoT (November 2016)
AWS CloudFormation (February 2016)
Devops with Amazon Web Services (January 2017)
Ad

Viewers also liked (20)

PDF
Viadeo - Cost Driven Development
PDF
The AWS DevOps combo (January 2017)
PDF
Bonnes pratiques pour la gestion des opérations de sécurité AWS
PDF
Amazon Inspector
PDF
Authentification et autorisation d'accès avec AWS IAM
PDF
Amazon AI (February 2017)
PDF
Big Data answers in seconds with Amazon Athena
PPT
Iot og personvern 2017
PPTX
Presentación dia de andalucia pedro
ODP
Com clonar i com exportar i importar una màquina virtual
PDF
Labo XX Antwerp - Densification strategies for the 20th century belt (BUUR)
PPTX
Filafat ilmu kepolisian
PDF
AWS re:Invent 2016 recap (part 2)
PDF
IoT: it's all about Data!
PDF
Repubblicanesimo, repubblicanismo, republicanismo, républicanisme, republican...
PDF
Postmarxismo, post marxismo, post marxismo
PPTX
Património Cultural Português - Panteões de Portugal e Edifícios da Soberania...
PPT
презентація впм технологія емалей 2017
PDF
Bonnes pratiques anti-DDOS
PDF
Stranger Danger: Securing Third Party Components (Tech2020)
Viadeo - Cost Driven Development
The AWS DevOps combo (January 2017)
Bonnes pratiques pour la gestion des opérations de sécurité AWS
Amazon Inspector
Authentification et autorisation d'accès avec AWS IAM
Amazon AI (February 2017)
Big Data answers in seconds with Amazon Athena
Iot og personvern 2017
Presentación dia de andalucia pedro
Com clonar i com exportar i importar una màquina virtual
Labo XX Antwerp - Densification strategies for the 20th century belt (BUUR)
Filafat ilmu kepolisian
AWS re:Invent 2016 recap (part 2)
IoT: it's all about Data!
Repubblicanesimo, repubblicanismo, republicanismo, républicanisme, republican...
Postmarxismo, post marxismo, post marxismo
Património Cultural Português - Panteões de Portugal e Edifícios da Soberania...
презентація впм технологія емалей 2017
Bonnes pratiques anti-DDOS
Stranger Danger: Securing Third Party Components (Tech2020)
Ad

Similar to Building Serverless APIs (January 2017) (20)

PDF
Čtvrtkon #64 - AWS Serverless - Michal Haták
PDF
Building serverless applications (April 2018)
PDF
用Serverless技術快速開發line聊天機器人
PDF
Python in the Serverless Era (PyCon IL 2016)
PPTX
Aws serverless architecture
PDF
Serverless Architecture - A Gentle Overview
PDF
Serverless architectures-with-aws-lambda
PDF
Getting Started with AWS Lambda & Serverless Cloud
PDF
AWSomeDay Zurich 2018 - How to go serverless
PPTX
Scheduled Retweets Using AWS Lambda
PPTX
Auto Retweets Using AWS Lambda
PDF
Writing and deploying serverless python applications
PDF
Building serverless backends - Tech talk 5 May 2017
PDF
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
PDF
Serverless Computing, AWS Way: SourceFuse Technologies
PDF
Serverless Computing, AWS Way by SourceFuse Technologies
PDF
Run Code, Not Servers: AWS Lambda
PDF
Serverless Meetup - 12 gennaio 2017
PDF
PyConIT 2018 Writing and deploying serverless python applications
PPTX
AWS Serverless Computing Introduction Session 2.pptx
Čtvrtkon #64 - AWS Serverless - Michal Haták
Building serverless applications (April 2018)
用Serverless技術快速開發line聊天機器人
Python in the Serverless Era (PyCon IL 2016)
Aws serverless architecture
Serverless Architecture - A Gentle Overview
Serverless architectures-with-aws-lambda
Getting Started with AWS Lambda & Serverless Cloud
AWSomeDay Zurich 2018 - How to go serverless
Scheduled Retweets Using AWS Lambda
Auto Retweets Using AWS Lambda
Writing and deploying serverless python applications
Building serverless backends - Tech talk 5 May 2017
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Serverless Computing, AWS Way: SourceFuse Technologies
Serverless Computing, AWS Way by SourceFuse Technologies
Run Code, Not Servers: AWS Lambda
Serverless Meetup - 12 gennaio 2017
PyConIT 2018 Writing and deploying serverless python applications
AWS Serverless Computing Introduction Session 2.pptx

More from Julien SIMON (20)

PDF
Implementing high-quality and cost-effiient AI applications with small langua...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
PDF
Arcee AI - building and working with small language models (06/25)
PDF
deep_dive_multihead_latent_attention.pdf
PDF
Deep Dive: Model Distillation with DistillKit
PDF
Deep Dive: Parameter-Efficient Model Adaptation with LoRA and Spectrum
PDF
Building High-Quality Domain-Specific Models with Mergekit
PDF
Tailoring Small Language Models for Enterprise Use Cases
PDF
Tailoring Small Language Models for Enterprise Use Cases
PDF
Julien Simon - Deep Dive: Compiling Deep Learning Models
PDF
Tailoring Small Language Models for Enterprise Use Cases
PDF
Julien Simon - Deep Dive - Optimizing LLM Inference
PDF
Julien Simon - Deep Dive - Accelerating Models with Better Attention Layers
PDF
Julien Simon - Deep Dive - Quantizing LLMs
PDF
Julien Simon - Deep Dive - Model Merging
PDF
An introduction to computer vision with Hugging Face
PDF
Reinventing Deep Learning
 with Hugging Face Transformers
PDF
Building NLP applications with Transformers
PPTX
Building Machine Learning Models Automatically (June 2020)
Implementing high-quality and cost-effiient AI applications with small langua...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Trying to figure out MCP by actually building an app from scratch with open s...
Arcee AI - building and working with small language models (06/25)
deep_dive_multihead_latent_attention.pdf
Deep Dive: Model Distillation with DistillKit
Deep Dive: Parameter-Efficient Model Adaptation with LoRA and Spectrum
Building High-Quality Domain-Specific Models with Mergekit
Tailoring Small Language Models for Enterprise Use Cases
Tailoring Small Language Models for Enterprise Use Cases
Julien Simon - Deep Dive: Compiling Deep Learning Models
Tailoring Small Language Models for Enterprise Use Cases
Julien Simon - Deep Dive - Optimizing LLM Inference
Julien Simon - Deep Dive - Accelerating Models with Better Attention Layers
Julien Simon - Deep Dive - Quantizing LLMs
Julien Simon - Deep Dive - Model Merging
An introduction to computer vision with Hugging Face
Reinventing Deep Learning
 with Hugging Face Transformers
Building NLP applications with Transformers
Building Machine Learning Models Automatically (June 2020)

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation theory and applications.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
Teaching material agriculture food technology
PDF
Modernizing your data center with Dell and AMD
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf
A Presentation on Artificial Intelligence
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation theory and applications.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Teaching material agriculture food technology
Modernizing your data center with Dell and AMD
NewMind AI Weekly Chronicles - August'25 Week I
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

Building Serverless APIs (January 2017)

  • 1. ©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved Building serverless APIs Julien Simon, Principal Technical Evangelist, AWS julsimon@amazon.fr @julsimon
  • 2. Serverless architecture" =" Managed services " +" AWS Lambda" " Reference architectures: http://www.allthingsdistributed.com/2016/06/aws-lambda-serverless-reference-architectures.html
  • 3. AWS Lambda •  Announced at re:Invent 2014 •  Deploy pure functions in Java, Python, Node.js and C# •  Just code, without the infrastructure drama •  Built-in scalability and high availability •  Integrated with many AWS services •  Pay as you go •  Combination of execution time (100ms slots) & memory used •  Starts at $0.000000208 per 100ms •  Free tier available: first 1 million requests per month are free http://aws.amazon.com/lambda AWS re:Invent 2014 | (MBL202) NEW LAUNCH: Getting Started with AWS Lambda https://www.youtube.com/watch?v=UFj27laTWQA
  • 4. What can you do with AWS Lambda? •  Grow ‘connective tissue’ in your AWS infrastructure –  Example: http://www.slideshare.net/JulienSIMON5/building-a-serverless-pipeline •  Build event-driven applications •  Build APIs together with Amazon API Gateway •  RESTful APIs •  Resources, methods •  Stages http://aws.amazon.com/apigateway
  • 6. Typical development workflow 1.  Write and deploy a Lambda function 2.  Create and deploy a REST API with API Gateway 3.  Connect the API to the Lambda function 4.  Invoke the API 5.  Test, debug and repeat ;)
  • 7. " Simplifying Development " "Code samples available at https://github.com/juliensimon/aws/tree/master/lambda_frameworks " "
  • 8. The Serverless framework " formerly known as JAWS: Just AWS Without Servers •  Announced at re:Invent 2015 by Austen Collins and Ryan Pendergast •  Supports Node.js, as well as Python and Java (with restrictions) •  Auto-deploys and runs Lambda functions, locally or remotely •  Auto-deploys your Lambda event sources: API Gateway, S3, DynamoDB, etc. •  Creates all required infrastructure with CloudFormation •  Simple configuration in YML http://github.com/serverless/serverless https://serverless.com AWS re:Invent 2015 | (DVO209) https://www.youtube.com/watch?v=D_U6luQ6I90 & https://vimeo.com/141132756
  • 9. Serverless: “Hello World” API $ serverless create Edit handler.js, serverless.yml and event.json $ serverless deploy [--stage stage_name] $ serverless invoke [--local] --function function_name $ serverless info $ http $URL
  • 10. Gordon •  Released in Oct’15 by Jorge Batista •  Supports Python, Javascript, Golang, Java, Scala, Kotlin (including in the same project) •  Auto-deploys and runs Lambda functions, locally or remotely •  Auto-deploys your Lambda event sources: API Gateway, CloudWatch Events, DynamoDB Streams, Kinesis Streams, S3 •  Creates all required infrastructure with CloudFormation •  Simple configuration in YML https://github.com/jorgebastida/gordon https://news.ycombinator.com/item?id=11821295
  • 11. Gordon: “Hello World” API $ gordon startproject helloworld $ gordon startapp helloapp Write hellofunc() function $ gordon build $ echo '{"name":"Julien"}' | gordon run helloapp.hellofunc $ gordon apply [--stage stage_name] $ http post $URL name=Julien
  • 12. AWS Chalice " Think of it as a serverless framework for Flask apps" •  Released in Jul’16, still in beta •  Just add your Python code –  Deploy with a single call and zero config –  The API is created automatically, the IAM policy is auto-generated •  Run APIs locally on port 8000 (similar to Flask) •  Fast & lightweight framework –  100% boto3 calls (AWS SDK for Python) à fast –  No integration with CloudFormation à no creation of event sources https://github.com/awslabs/chalice https://aws.amazon.com/blogs/developer/preview-the-python-serverless-microframework-for-aws/
  • 13. AWS Chalice: “Hello World” API $ chalice new-project helloworld Write your function in app.py $ chalice local $ chalice deploy $ export URL=`chalice url` $ http $URL $ http put $URL/hello/julien $ chalice logs [ --include-lambda-messages ]
  • 14. AWS Chalice: PUT/GET in S3 bucket $ chalice new-project s3test Write your function in app.py $ chalice local $ http put http://localhost:8000/objects/doc.json value1=5 value2=8 $ http get http://localhost:8000/objects/doc.json $ chalice deploy [stage_name] $ export URL=`chalice url` $ http put $URL/objects/doc.json value1=5 value2=8 $ http get $URL/objects/doc.json
  • 15. Summing things up Serverless The most popular serverless framework Built with and for Node.js. Python and Java: YMMV Rich features, many event sources Not a web framework Gordon Great challenger! Node.js, Python, Java, Scala, Golang Comparable to Serverless feature-wise Not a web framework Chalice AWS project, in beta Python only Does only one thing, but does it great Dead simple, zero config Flask web framework
  • 16. More Lambda frameworks •  Kappa https://github.com/garnaat/kappa –  Released Dec’14 by Mitch Garnaat, author of boto and the AWS CLI (still maintained?) –  Python only, multiple event sources •  Apex https://github.com/apex/apex –  Released in Dec’15 by TJ Holowaychuk –  Python, Javascript, Java, Golang –  Terraform integration to manage infrastructure for event sources •  Zappa https://github.com/Miserlou/Zappa –  Released in Feb’16 by Rich Jones –  Python web applications on AWS Lambda + API Gateway •  Docker-lambda https://github.com/lambci/docker-lambda –  Released in May’16 by Michael Hart –  Run functions in Docker images that “replicate” the live Lambda environment
  • 17. 2 Java tools for AWS Lambda https://java.awsblog.com/post/TxWZES6J1RSQ2Z/Testing-Lambda-functions-using-the-AWS-Toolkit-for-Eclipse https://aws.amazon.com/blogs/developer/aws-toolkit-for-eclipse-serverless-application https://github.com/awslabs/aws-serverless-java-container Eclipse plug-in •  Code, test and deploy Lambdas from Eclipse •  Run your functions locally and remotely •  Test with local events and Junit4 •  Deploy standalone functions, or with the " AWS Serverless Application Model (Dec’16) Serverless Java Container •  Run Java RESTful APIs as-is •  Default implementation of the Java servlet HttpServletRequest " HttpServletResponse •  Support for Java frameworks such as Jersey or Spark
  • 19. AWS Serverless Application Model (SAM)" •  CloudFormation extension released in Nov’16 to bundle Lambda functions, APIs & events •  3 new CloudFormation resource types –  AWS::Serverless::Function –  AWS::Serverless::Api –  AWS::Serverless::SimpleTable (DynamoDB) •  2 new CloudFormation CLI commands –  ‘aws cloudformation package’ –  ‘aws cloudformation deploy’ •  Integration with CodeBuild and CodePipeline for CI/CD •  Expect SAM to be integrated in most / all frameworks https://aws.amazon.com/fr/blogs/compute/introducing-simplified-serverless-application-deplyoment-and-management https://github.com/awslabs/serverless-application-model/
  • 20. AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Get items from a DynamoDB table. Resources: GetFunction: Type: AWS::Serverless::Function Properties: Handler: index.get Runtime: nodejs4.3 Policies: AmazonDynamoDBReadOnlyAccess Environment: Variables: TABLE_NAME: !Ref Table Events: GetResource: Type: Api Properties: Path: /resource/{resourceId} Method: get Table: Type: AWS::Serverless::SimpleTable Sample SAM template for: •  Lambda function •  HTTP GET API •  DynamoDB table
  • 22. The AWS edge North America South America EMEA APAC POPs Cities Countries Continents Regional Edge Caches
  • 23. Lambda@Edge •  Lambda@Edge is an extension of AWS Lambda that allows you to run Node.js code at AWS global edge locations. •  Bring your own code to the edge and customize your content very close to your users, improving the end-user experience. •  Typical use cases •  Customize content, based on user/device properties •  Validate visitors: check tokens, filter bot traffic •  Rewrite URLs: inject ads, hide file structure •  Run A/B testing
  • 24. CloudFront Triggers for " Lambda@Edge Functions
  • 25. Lambda@Edge Service Limits Items Lambda@Edge Lambda Timeout 50 ms 300 seconds Function “Power Level” 128 MB 128 MB – 1.5 GB Function Deployment Package Size 1MB 50MB •  Runtime: Node.js 4.3 •  Triggered by CloudFront events •  Access: No network connections, AWS region access, disk access or Amazon VPC
  • 26. Lambda@Edge demo: the Metal A/B test m/ •  Static website in S3, distributed to CloudFront http://d2eb9d90qk3238.cloudfront.net •  The index page references an image file that doesn’t exist in the S3 bucket <img src="http://d2eb9d90qk3238.cloudfront.net/album.jpg"> •  A Lambda function is triggered on the “Origin request” event and replaces album.jpg with a random file
  • 28. New Lambda videos from re:Invent 2016 AWS re:Invent 2016: What’s New with AWS Lambda (SVR202) https://www.youtube.com/watch?v=CwxWhyGteNc AWS re:Invent 2016: Serverless Apps with AWS Step Functions (SVR201) https://www.youtube.com/watch?v=75MRve4nv8s AWS re:Invent 2016: Real-time Data Processing Using AWS Lambda (SVR301) https://www.youtube.com/watch?v=VFLKOy4GKXQ AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC402) https://www.youtube.com/watch?v=b7UMoc1iUYw ‪AWS re:Invent 2016: Bringing AWS Lambda to the Edge (CTD206)‬ https://www.youtube.com/watch?v=j26novaqF6M ‪AWS re:Invent 2016: Ubiquitous Computing with Greengrass (IOT201)‬ https://www.youtube.com/watch?v=XQQjX8GTEko
  • 29. The only Lambda book you need to read Written by AWS Technical Evangelist Danilo Poccia Released in December 2016 https://www.amazon.com/Aws-Lambda-Action- Event-driven-Applications/dp/1617293717/