SlideShare a Scribd company logo
1 of 22
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Layers and Runtime API
Danilo Poccia
Principal Evangelist, Serverless
@danilop
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Agenda
Lambda Layers
Lambda Runtime API
Demo
Lambda Layers
Photo by Thibault Mokuenko on Unsplash
A way to centrally manage code and data
that is shared across multiple functions
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Layers Use Cases
Custom code that is used by
multiple functions, Partner
libraries, etc.
Shared code that doesn’t change
frequently
Layers can be shared across
Accounts, publicly with any
Account and all Accounts within
an Organization
Lambda
Layers
Lambda
Function
Lambda
Function
Lambda
Layers
Account A Account B
Same-account Layers
Lambda
Layers
Icon made by Freepik from www.flaticon.com
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using Lambda Layers
Put common components in a ZIP file
and upload it as a Lambda Layer
Layers are immutable and can be
versioned to manage updates
When a version is deleted or
permissions to use it are revoked,
functions that used it previously will
continue to work, but you won’t be
able to create new ones
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib:1
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib:2
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib:3
Icon made by Freepik from www.flaticon.com
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using Lambda Layers
You can reference up to five layers,
one of which can optionally be a
custom runtime
When the function is invoked, layers
are installed in the execution
environment in the order you
provided
The overall, uncompressed size of
function and layers is subject to the
usual unzipped deployment package
size limit (250MB)
Lambda
Layers
Lambda
Function
Lambda
Layers
Lambda
Layers
Lambda
Layers
Lambda
Layers
Up to 5 Layers
/opt NodeJS v11.X provided runtime
/opt Node runtime + node_modules
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Including Library Dependencies in a Layer
Runtime Folders
Node.js
nodejs/node_modules
nodejs/node8/node_modules (NODE_PATH)
Python
python
python/lib/python3.7/site-packages (site directories)
Java java/lib (CLASSPATH)
Ruby
ruby/gems/2.5.0 (GEM_PATH)
ruby/lib (RUBY_LIB)
All
bin (PATH)
lib (LD_LIBRARY_PATH)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Layers API
New APIs
• ListLayers
• ListLayerVersions
• PublishLayerVersion
• DeleteLayerVersion
• GetLayerVersion
• GetLayerVersionPolicy
• AddLayerVersionPermission
• RemoveLayerVersionPermission
Updated
• CreateFunction
• UpdateFunctionConfiguration
docs.aws.amazon.com/lambda/latest/dg/API_Reference.html
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM support
BashRuntime:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: bash-sam
Description: Bash Runtime FWIW
ContentUri: bash_runtime
LicenseInfo: 'MIT-0 license’
RetentionPolicy: Retain
HelloBashFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: bash_hello
Handler: hello.handler
Runtime: provided
Layers:
- !Ref BashRuntime
- <LayerTwoArn>
New AWS::Serverless::LayerVersion
resource creates new Lambda Layer
from local filesystem or S3 URI
Layers can also be restricted to certain
Runtimes (CompatibleRuntimes
property)
SAM CLI 0.8.1+ supports Layers locally
and remotely (ARN)
Lambda Runtime API
Photo by Jeremy Lapak on Unsplash
A simple interface to use
any programming
language, or a specific
language version, for
developing your
functions
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Runtime API
Select a custom runtime in the console
(provided in the API/SDKs/CLI) as the
runtime of a Lambda function
The Function must include (in its code
or in a layer) an executable file
called bootstrap
The runtime bootstrap is responsible for
the communication between your code
and the Lambda environment
Bash FWIW
docs.aws.amazon.com/lambda/latest/dg/runtimes-walkthrough.html
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Runtime Boostrap
The bootstrap executable act as a bridge
between the Runtime HTTP API and the
Function to be executed
Bootstrap needs to manage response/error
handling, context creation and function
execution
Information on the interface endpoint and
the function handler are shared as
environment variables
/runtime API
/invocation/next
/init/error /ID/error
/invocation/ID/response
/invocation/ID/error
bootstrap
Process events/headers
Clean up
Initialize and Invoke function
Response/Error handling
Lambda
Function
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Runtime API - Environment Variables
• AWS_LAMBDA_RUNTIME_API
• HOSTNAME:PORT
• _HANDLER
• SCRIPT_NAME.FUNCTION_NAME
• LAMBDA_TASK_ROOT
• The directory that contains the function code
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Runtime API - Runtime Interactions
• POST /runtime/init/error
• GET /runtime/invocation/next
• The invocation-id is in the Lambda-Runtime-Aws-Request-Id header
• For AWS X-Ray there is a tracing header Lambda-Runtime-Trace-Id
• POST /runtime/invocation/{invocation-id}/response
• POST /runtime/invocation/{invocation-id}/error
• Sample Endpoint + Resource Path
• http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next
More info and OpenAPI specification available: docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Open Source Runtimes already available
C++ (AWS)
Rust (AWS)
Nim (LambCI)
Erlang (Alert Logic)
Elixir (Alert Logic)
Cobol (Blu Age)
Node.js (NodeSource N|Solid)
PHP (Stackery)
github.com/mthenw/awesome-layers
Check this out for more links
Demo
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Layers Demo
• Node.js
• Creating a layer with moment.js, request, and request-promise
• Using the layer
• Python
• SciPy & NumPy layer example
• Adding a matplotlib layer
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Runtime API Demo
• Creating a Custom Runtime for… Bash functions!
• Bootstrap
• hello.sh
Photo by Christoph Krichenbauer on Unsplash
What are you going to build?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!
@danilop

More Related Content

What's hot

CQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsCQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsMichael Blackstock
 
Managing multiple event types in a single topic with Schema Registry | Bill B...
Managing multiple event types in a single topic with Schema Registry | Bill B...Managing multiple event types in a single topic with Schema Registry | Bill B...
Managing multiple event types in a single topic with Schema Registry | Bill B...HostedbyConfluent
 
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...Amazon Web Services
 
Kafka and Avro with Confluent Schema Registry
Kafka and Avro with Confluent Schema RegistryKafka and Avro with Confluent Schema Registry
Kafka and Avro with Confluent Schema RegistryJean-Paul Azar
 
Demystifying the Distributed Database Landscape (DevOps) (1).pdf
Demystifying the Distributed Database Landscape (DevOps) (1).pdfDemystifying the Distributed Database Landscape (DevOps) (1).pdf
Demystifying the Distributed Database Landscape (DevOps) (1).pdfScyllaDB
 
IAM Introduction and Best Practices
IAM Introduction and Best PracticesIAM Introduction and Best Practices
IAM Introduction and Best PracticesAmazon Web Services
 
HDFS for Geographically Distributed File System
HDFS for Geographically Distributed File SystemHDFS for Geographically Distributed File System
HDFS for Geographically Distributed File SystemKonstantin V. Shvachko
 
Webinar AWS 201 - Using Amazon Virtual Private Cloud (VPC)
Webinar AWS 201 - Using Amazon Virtual Private Cloud (VPC)Webinar AWS 201 - Using Amazon Virtual Private Cloud (VPC)
Webinar AWS 201 - Using Amazon Virtual Private Cloud (VPC)Amazon Web Services
 
Kafka MirrorMaker: Disaster Recovery, Scaling Reads, Isolate Mission Critical...
Kafka MirrorMaker: Disaster Recovery, Scaling Reads, Isolate Mission Critical...Kafka MirrorMaker: Disaster Recovery, Scaling Reads, Isolate Mission Critical...
Kafka MirrorMaker: Disaster Recovery, Scaling Reads, Isolate Mission Critical...Jean-Paul Azar
 
AWS KMS 에서 제공하는 봉투암호화 방식의 암호화 및 사이닝 기능에 대한 소개와 실습 - 신은수, AWS 솔루션즈 아키텍트 :: AWS...
AWS KMS 에서 제공하는 봉투암호화 방식의 암호화 및 사이닝 기능에 대한 소개와 실습 - 신은수, AWS 솔루션즈 아키텍트 :: AWS...AWS KMS 에서 제공하는 봉투암호화 방식의 암호화 및 사이닝 기능에 대한 소개와 실습 - 신은수, AWS 솔루션즈 아키텍트 :: AWS...
AWS KMS 에서 제공하는 봉투암호화 방식의 암호화 및 사이닝 기능에 대한 소개와 실습 - 신은수, AWS 솔루션즈 아키텍트 :: AWS...Amazon Web Services Korea
 
Cross-account encryption with AWS KMS and Slack Enterprise Key Management - S...
Cross-account encryption with AWS KMS and Slack Enterprise Key Management - S...Cross-account encryption with AWS KMS and Slack Enterprise Key Management - S...
Cross-account encryption with AWS KMS and Slack Enterprise Key Management - S...Amazon Web Services
 
NETCONF Call Home
NETCONF Call Home NETCONF Call Home
NETCONF Call Home ADVA
 

What's hot (18)

Introduction to CloudFront
Introduction to CloudFrontIntroduction to CloudFront
Introduction to CloudFront
 
CQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsCQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applications
 
Construyendo aplicaciones Serverless
Construyendo aplicaciones ServerlessConstruyendo aplicaciones Serverless
Construyendo aplicaciones Serverless
 
Managing multiple event types in a single topic with Schema Registry | Bill B...
Managing multiple event types in a single topic with Schema Registry | Bill B...Managing multiple event types in a single topic with Schema Registry | Bill B...
Managing multiple event types in a single topic with Schema Registry | Bill B...
 
The Google Bigtable
The Google BigtableThe Google Bigtable
The Google Bigtable
 
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...
Running a High-Performance Kubernetes Cluster with Amazon EKS (CON318-R1) - A...
 
Kafka and Avro with Confluent Schema Registry
Kafka and Avro with Confluent Schema RegistryKafka and Avro with Confluent Schema Registry
Kafka and Avro with Confluent Schema Registry
 
Demystifying the Distributed Database Landscape (DevOps) (1).pdf
Demystifying the Distributed Database Landscape (DevOps) (1).pdfDemystifying the Distributed Database Landscape (DevOps) (1).pdf
Demystifying the Distributed Database Landscape (DevOps) (1).pdf
 
IAM Introduction and Best Practices
IAM Introduction and Best PracticesIAM Introduction and Best Practices
IAM Introduction and Best Practices
 
Kafka: Internals
Kafka: InternalsKafka: Internals
Kafka: Internals
 
HDFS for Geographically Distributed File System
HDFS for Geographically Distributed File SystemHDFS for Geographically Distributed File System
HDFS for Geographically Distributed File System
 
Webinar AWS 201 - Using Amazon Virtual Private Cloud (VPC)
Webinar AWS 201 - Using Amazon Virtual Private Cloud (VPC)Webinar AWS 201 - Using Amazon Virtual Private Cloud (VPC)
Webinar AWS 201 - Using Amazon Virtual Private Cloud (VPC)
 
Hp Virtual Connect
Hp Virtual ConnectHp Virtual Connect
Hp Virtual Connect
 
Deep Dive on AWS IoT Core
Deep Dive on AWS IoT CoreDeep Dive on AWS IoT Core
Deep Dive on AWS IoT Core
 
Kafka MirrorMaker: Disaster Recovery, Scaling Reads, Isolate Mission Critical...
Kafka MirrorMaker: Disaster Recovery, Scaling Reads, Isolate Mission Critical...Kafka MirrorMaker: Disaster Recovery, Scaling Reads, Isolate Mission Critical...
Kafka MirrorMaker: Disaster Recovery, Scaling Reads, Isolate Mission Critical...
 
AWS KMS 에서 제공하는 봉투암호화 방식의 암호화 및 사이닝 기능에 대한 소개와 실습 - 신은수, AWS 솔루션즈 아키텍트 :: AWS...
AWS KMS 에서 제공하는 봉투암호화 방식의 암호화 및 사이닝 기능에 대한 소개와 실습 - 신은수, AWS 솔루션즈 아키텍트 :: AWS...AWS KMS 에서 제공하는 봉투암호화 방식의 암호화 및 사이닝 기능에 대한 소개와 실습 - 신은수, AWS 솔루션즈 아키텍트 :: AWS...
AWS KMS 에서 제공하는 봉투암호화 방식의 암호화 및 사이닝 기능에 대한 소개와 실습 - 신은수, AWS 솔루션즈 아키텍트 :: AWS...
 
Cross-account encryption with AWS KMS and Slack Enterprise Key Management - S...
Cross-account encryption with AWS KMS and Slack Enterprise Key Management - S...Cross-account encryption with AWS KMS and Slack Enterprise Key Management - S...
Cross-account encryption with AWS KMS and Slack Enterprise Key Management - S...
 
NETCONF Call Home
NETCONF Call Home NETCONF Call Home
NETCONF Call Home
 

Similar to re:Invent Deep Dive on Lambda Layers and Runtime API

[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018
[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018
[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018Amazon Web Services
 
How to Use AWS Lambda Layers and Lambda Runtime
How to Use AWS Lambda Layers and Lambda RuntimeHow to Use AWS Lambda Layers and Lambda Runtime
How to Use AWS Lambda Layers and Lambda RuntimeDonnie Prakoso
 
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)Amazon Web Services
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep DiveAmazon Web Services
 
Deep Dive on Serverless Application Development
Deep Dive on Serverless Application DevelopmentDeep Dive on Serverless Application Development
Deep Dive on Serverless Application DevelopmentAmazon Web Services
 
Serverless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversServerless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversAmazon Web Services
 
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...Amazon Web Services
 
Deep Dive On Serverless Application Development
Deep Dive On Serverless Application DevelopmentDeep Dive On Serverless Application Development
Deep Dive On Serverless Application DevelopmentAmazon Web Services
 
Deep Dive on Serverless Application Development - Zlatan Dzinic
Deep Dive on Serverless Application Development - Zlatan DzinicDeep Dive on Serverless Application Development - Zlatan Dzinic
Deep Dive on Serverless Application Development - Zlatan DzinicAmazon Web Services
 
Deep Dive on Serverless Application Development
Deep Dive on Serverless Application DevelopmentDeep Dive on Serverless Application Development
Deep Dive on Serverless Application DevelopmentAmazon Web Services
 
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018Amazon Web Services
 
Build and Deploy Serverless Applications with AWS SAM
Build and Deploy Serverless Applications with AWS SAM Build and Deploy Serverless Applications with AWS SAM
Build and Deploy Serverless Applications with AWS SAM Amazon Web Services
 
Legacy java ee meet lambda
Legacy java ee  meet lambdaLegacy java ee  meet lambda
Legacy java ee meet lambdaKim Kao
 
The Best Practices and Hard Lessons Learned of Serverless Applications
The Best Practices and Hard Lessons Learned of Serverless ApplicationsThe Best Practices and Hard Lessons Learned of Serverless Applications
The Best Practices and Hard Lessons Learned of Serverless ApplicationsAmazon Web Services LATAM
 
Serverless Developer Experience I AWS Dev Day 2018
Serverless Developer Experience I AWS Dev Day 2018Serverless Developer Experience I AWS Dev Day 2018
Serverless Developer Experience I AWS Dev Day 2018AWS Germany
 
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS SummitBuilding serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS SummitAmazon Web Services
 
Forza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni ServerlessForza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni ServerlessAmazon Web Services
 

Similar to re:Invent Deep Dive on Lambda Layers and Runtime API (20)

[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018
[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018
[NEW LAUNCH!] Lambda Layers (SRV375) - AWS re:Invent 2018
 
How to Use AWS Lambda Layers and Lambda Runtime
How to Use AWS Lambda Layers and Lambda RuntimeHow to Use AWS Lambda Layers and Lambda Runtime
How to Use AWS Lambda Layers and Lambda Runtime
 
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
使用 AWS 無伺服器化應用程式模型 (SAM) 釋放您的 "敏捷" 能量 (Level 300)
 
Lambda Layers & Runtime API
Lambda Layers & Runtime APILambda Layers & Runtime API
Lambda Layers & Runtime API
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
 
Deep Dive on Serverless Application Development
Deep Dive on Serverless Application DevelopmentDeep Dive on Serverless Application Development
Deep Dive on Serverless Application Development
 
Serverless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversServerless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about servers
 
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
Unlocking Agility with the AWS Serverless Application Model (SAM) - AWS Summi...
 
The serverless LAMP stack
The serverless LAMP stackThe serverless LAMP stack
The serverless LAMP stack
 
Deep Dive On Serverless Application Development
Deep Dive On Serverless Application DevelopmentDeep Dive On Serverless Application Development
Deep Dive On Serverless Application Development
 
Deep Dive on Serverless Application Development - Zlatan Dzinic
Deep Dive on Serverless Application Development - Zlatan DzinicDeep Dive on Serverless Application Development - Zlatan Dzinic
Deep Dive on Serverless Application Development - Zlatan Dzinic
 
Deep Dive on Serverless Application Development
Deep Dive on Serverless Application DevelopmentDeep Dive on Serverless Application Development
Deep Dive on Serverless Application Development
 
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018
Driving Innovation with Serverless Applications (GPSBUS212) - AWS re:Invent 2018
 
Build and Deploy Serverless Applications with AWS SAM
Build and Deploy Serverless Applications with AWS SAM Build and Deploy Serverless Applications with AWS SAM
Build and Deploy Serverless Applications with AWS SAM
 
Devops on serverless
Devops on serverlessDevops on serverless
Devops on serverless
 
Legacy java ee meet lambda
Legacy java ee  meet lambdaLegacy java ee  meet lambda
Legacy java ee meet lambda
 
The Best Practices and Hard Lessons Learned of Serverless Applications
The Best Practices and Hard Lessons Learned of Serverless ApplicationsThe Best Practices and Hard Lessons Learned of Serverless Applications
The Best Practices and Hard Lessons Learned of Serverless Applications
 
Serverless Developer Experience I AWS Dev Day 2018
Serverless Developer Experience I AWS Dev Day 2018Serverless Developer Experience I AWS Dev Day 2018
Serverless Developer Experience I AWS Dev Day 2018
 
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS SummitBuilding serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
 
Forza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni ServerlessForza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni Serverless
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

re:Invent Deep Dive on Lambda Layers and Runtime API

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Layers and Runtime API Danilo Poccia Principal Evangelist, Serverless @danilop
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda Lambda Layers Lambda Runtime API Demo
  • 4. Photo by Thibault Mokuenko on Unsplash A way to centrally manage code and data that is shared across multiple functions
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Layers Use Cases Custom code that is used by multiple functions, Partner libraries, etc. Shared code that doesn’t change frequently Layers can be shared across Accounts, publicly with any Account and all Accounts within an Organization Lambda Layers Lambda Function Lambda Function Lambda Layers Account A Account B Same-account Layers Lambda Layers Icon made by Freepik from www.flaticon.com
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using Lambda Layers Put common components in a ZIP file and upload it as a Lambda Layer Layers are immutable and can be versioned to manage updates When a version is deleted or permissions to use it are revoked, functions that used it previously will continue to work, but you won’t be able to create new ones Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib:1 Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib:2 Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib:3 Icon made by Freepik from www.flaticon.com
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using Lambda Layers You can reference up to five layers, one of which can optionally be a custom runtime When the function is invoked, layers are installed in the execution environment in the order you provided The overall, uncompressed size of function and layers is subject to the usual unzipped deployment package size limit (250MB) Lambda Layers Lambda Function Lambda Layers Lambda Layers Lambda Layers Lambda Layers Up to 5 Layers /opt NodeJS v11.X provided runtime /opt Node runtime + node_modules
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Including Library Dependencies in a Layer Runtime Folders Node.js nodejs/node_modules nodejs/node8/node_modules (NODE_PATH) Python python python/lib/python3.7/site-packages (site directories) Java java/lib (CLASSPATH) Ruby ruby/gems/2.5.0 (GEM_PATH) ruby/lib (RUBY_LIB) All bin (PATH) lib (LD_LIBRARY_PATH)
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Layers API New APIs • ListLayers • ListLayerVersions • PublishLayerVersion • DeleteLayerVersion • GetLayerVersion • GetLayerVersionPolicy • AddLayerVersionPermission • RemoveLayerVersionPermission Updated • CreateFunction • UpdateFunctionConfiguration docs.aws.amazon.com/lambda/latest/dg/API_Reference.html
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM support BashRuntime: Type: AWS::Serverless::LayerVersion Properties: LayerName: bash-sam Description: Bash Runtime FWIW ContentUri: bash_runtime LicenseInfo: 'MIT-0 license’ RetentionPolicy: Retain HelloBashFunction: Type: AWS::Serverless::Function Properties: CodeUri: bash_hello Handler: hello.handler Runtime: provided Layers: - !Ref BashRuntime - <LayerTwoArn> New AWS::Serverless::LayerVersion resource creates new Lambda Layer from local filesystem or S3 URI Layers can also be restricted to certain Runtimes (CompatibleRuntimes property) SAM CLI 0.8.1+ supports Layers locally and remotely (ARN)
  • 12. Photo by Jeremy Lapak on Unsplash A simple interface to use any programming language, or a specific language version, for developing your functions
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Runtime API Select a custom runtime in the console (provided in the API/SDKs/CLI) as the runtime of a Lambda function The Function must include (in its code or in a layer) an executable file called bootstrap The runtime bootstrap is responsible for the communication between your code and the Lambda environment Bash FWIW docs.aws.amazon.com/lambda/latest/dg/runtimes-walkthrough.html
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Runtime Boostrap The bootstrap executable act as a bridge between the Runtime HTTP API and the Function to be executed Bootstrap needs to manage response/error handling, context creation and function execution Information on the interface endpoint and the function handler are shared as environment variables /runtime API /invocation/next /init/error /ID/error /invocation/ID/response /invocation/ID/error bootstrap Process events/headers Clean up Initialize and Invoke function Response/Error handling Lambda Function
  • 15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Runtime API - Environment Variables • AWS_LAMBDA_RUNTIME_API • HOSTNAME:PORT • _HANDLER • SCRIPT_NAME.FUNCTION_NAME • LAMBDA_TASK_ROOT • The directory that contains the function code
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Runtime API - Runtime Interactions • POST /runtime/init/error • GET /runtime/invocation/next • The invocation-id is in the Lambda-Runtime-Aws-Request-Id header • For AWS X-Ray there is a tracing header Lambda-Runtime-Trace-Id • POST /runtime/invocation/{invocation-id}/response • POST /runtime/invocation/{invocation-id}/error • Sample Endpoint + Resource Path • http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next More info and OpenAPI specification available: docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Open Source Runtimes already available C++ (AWS) Rust (AWS) Nim (LambCI) Erlang (Alert Logic) Elixir (Alert Logic) Cobol (Blu Age) Node.js (NodeSource N|Solid) PHP (Stackery) github.com/mthenw/awesome-layers Check this out for more links
  • 18. Demo
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Layers Demo • Node.js • Creating a layer with moment.js, request, and request-promise • Using the layer • Python • SciPy & NumPy layer example • Adding a matplotlib layer
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Runtime API Demo • Creating a Custom Runtime for… Bash functions! • Bootstrap • hello.sh
  • 21. Photo by Christoph Krichenbauer on Unsplash What are you going to build?
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you! @danilop