SlideShare ist ein Scribd-Unternehmen logo
1 von 41
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Pop-up Loft
AWS Lambda Layers and the Runtime API
Chris Munns
Principal Developer Advocate
AWS Serverless
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
About me:
Chris Munns - munns@amazon.com, @chrismunns
– Principal 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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
https://secure.flickr.com/photos/mgifford/4525333972
Why are we
here today?
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Serverless applications
Services (anything)
Changes in
data state
Requests to
endpoints
Changes in
resource state
Event source Function
Node.js
Python
Java
C#
Go
Ruby
Runtime API
© 2019, 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, more)
public String handleRequest(Book book, Context context) {
saveBook(book);
return book.getName() + " saved!";
}
Anatomy of a Lambda function
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Anatomy of a Lambda function
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Functions will then grow in complexity with business logic sub-functions
Anatomy of a Lambda functionImport sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Business logic sub-functions
Anatomy of a Lambda functionImport sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration information, common helper functions
Common helper functions
Business logic sub-functions
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Anatomy of a serverless application
Amazon API
Gateway
/orders
/forums
/search
/lists
/user
/...
Now assume that I
have an API based
workload
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Anatomy of a serverless application
Databases/
Data stores
AWS Secrets
Manager / AWS
Parameter Store
It needs to read/write
to a DB and get keys
and configuration from
external services
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Anatomy of a serverless application
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Amazon API
Gateway
/orders
/forums
/search
/lists
/user
/...
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Databases/
Data stores
AWS Secrets
Manager / AWS
Parameter Store
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Anatomy of a serverless application
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Amazon API
Gateway
/orders
/forums
/search
/lists
/user
/...
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Pre-handler-secret-getter() {
}
Function Pre-handler-db-connect(){
}
Function subFunctionA(thing){
## logic here
}
Function subFunctionA(thing){
## logic here
}
Dependencies, configuration
information, common helper
functions
Common helper functions
Business logic sub-functions
Databases/
Data stores
AWS Secrets
Manager / AWS
Parameter Store
There could be a lot of
duplicated code here!
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Anatomy of a serverless application
Amazon API
Gateway
/orders
/forums
/search
/lists
/user
/...
Databases/
Data stores
AWS Secrets
Manager / AWS
Parameter Store
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function
Import sdk
Import http-lib
Import ham-sandwich
Pre-handler-secret-getter()
Pre-handler-db-connect()
Function myhandler(event, context) {
<Event handling logic> {
result = SubfunctionA()
}else {
result = SubfunctionB()
return result;
}
Function
Dependencies, configuration information,
common helper functions
Common helper functions
Business logic sub-functions
We want something
more like this:
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Lambda Layers
Lets functions easily share code: Upload layer
once, reference within any function
Layer can be anything: dependencies, training
data, configuration files, etc
Promote separation of responsibilities, lets
developers iterate faster on writing business logic
Built in support for secure sharing by ecosystem
© 2019, 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
• You can reference up to five layers, one of
which can optionally be a custom runtime
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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
How Lambda Layers Work
• Order is important because each layer is a ZIP file, and they are all
extracted in the same path
– /opt
– Each layer can potentially overwrite the previous one
• This approach can be used to customize the environment
– For example, the first layer can be a custom runtime and the second layer
adds specific versions of the libraries you need
• The storage of your Lambda Layers takes part in the AWS
Lambda Function storage per region limit (75GB)
© 2019, 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)
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Lambda Layers Permissions
• Layers can be used within
– An AWS account
– Shared between accounts
– Shared publicly with the broad developer community
• AWS published a public layer which includes NumPy and SciPy, two
popular scientific libraries for Python
– This prebuilt and optimized layer can help you start very quickly with
data processing and machine learning applications
• More from AWS coming!
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
DEMO!
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
AWS Lambda wants to make
it easy for developers to get
started writing applications
without needing to worry
about installing software on
servers or in containers
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Managing the language
runtimes for our
customers helps make it
easier to do this!
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Currently supported languages and versions
• Node.js 6.10
• Node.js 8.10
• Python 2.7
• Python 3.6
• Python 3.7
• Go 1.x
• Ruby 2.5
• Java 8
• .Net Core 1.0 (C#)
• .Net Core 2.0 (C#)
• .Net Core 2.1
(C#/PowerShell)
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Currently supported languages and versions
• Node.js 6.10
• Node.js 8.10
• Python 2.7
• Python 3.6
• Python 3.7
• Go 1.x
• Ruby 2.5
• Java 8
• .Net Core 1.0 (C#)
• .Net Core 2.0 (C#)
• .Net Core 2.1
(C#/PowerShell)
These represent the majority of what our customers
are writing applications in today...
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
But there’s a long longtail of other languages..
• The Stack Overflow “Developer Survey” from
2018 mentioned 25 different languages
(without versions) used by developers.
• https://insights.stackoverflow.com/survey/2018
• GitHub’s 2018 “State of the Octoverse” report
lists a top 10 as well as top 10 growing
languages including languages such as: Rust,
Groovy, and Kotlin.
• https://octoverse.github.com/projects
From Stack Overflow
Developer Survey 2018
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
But there’s a long longtail of other languages..
• The Stack Overflow “Developer Survey” from
2018 mentioned 25 different languages
(without versions) used by developers.
• https://insights.stackoverflow.com/survey/2018
• GitHub’s 2018 “State of the Octoverse” report
lists a top 10 as well as top 10 growing
languages including languages such as: Rust,
Groovy, and Kotlin.
• https://octoverse.github.com/projects
From Stack Overflow
Developer Survey 2018
Customers care about these, and we care about
you.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Lambda Custom Runtimes
Bring any Linux compatible language runtime
Powered by new Runtime API - Codifies the
runtime calling conventions and integration
points
At launch, custom runtimes powering Ruby
support in AWS Lambda, more runtimes from
partners (like Erlang)
Custom runtimes distributed as “layers”
Rule
Stack
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Lambda Runtime API
• You can now select a custom runtime in the console (provided in the
API/SDKs/CLI) as the runtime of a Lambda function
• With this selection, 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
• Your code can use any programming language
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Runtime Bootstrap
• The bootstrap executable acts 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
© 2019, 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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Lambda Runtime API - Processing Tasks
1. Get an event
2. Propagate tracing ID
3. Create a context object
4. Invoke the function handler
5. Handle the response
6. Handle errors
7. Cleanup
© 2019, 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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Using Custom Runtimes
• For the execution of your code, you can use anything that can run in
the Lambda execution environment.
– For example, you can bring an interpreter for the programming language of
your choice.
• You only need to know how the Runtime API works if you want to
manage or publish your own runtimes
• As a developer, you can quickly use runtimes that are shared with you
as layers
– Custom runtimes can be shared as layers so that developers can pick them
up and use their favorite programming language when authoring Lambda
functions
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
New: Open Source Runtimes
AWS OPEN SOURCE PARTNER SUPPORTED
o f f e r e d b y
o f f e r e d b y
o f f e r e d b y
o f f e r e d b y
Can find more here: https://github.com/mthenw/awesome-layers !
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Stackery’s PHP Lambda Layer
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
DEMO!
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
aws.amazon.com/serverless
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Chris Munns
munns@amazon.com
@chrismunnshttps://www.flickr.com/photos/theredproject/3302110152/
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
?
https://secure.flickr.com/photos/dullhunk/202872717/

Weitere ähnliche Inhalte

Ähnlich wie AWS Lambda Layers, the Runtime API, & Nested Applications

Best Practices and Hard Lessons of Serverless- AWS Startup Day Toronto- Diego...
Best Practices and Hard Lessons of Serverless- AWS Startup Day Toronto- Diego...Best Practices and Hard Lessons of Serverless- AWS Startup Day Toronto- Diego...
Best Practices and Hard Lessons of Serverless- AWS Startup Day Toronto- Diego...Amazon Web Services
 
End AWS Lambda Cold Starts with Provisioned Concurrency
End AWS Lambda Cold Starts with Provisioned ConcurrencyEnd AWS Lambda Cold Starts with Provisioned Concurrency
End AWS Lambda Cold Starts with Provisioned ConcurrencyJulian Wood
 
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
 
Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugToshiaki Maki
 
SRV328 Designing and Implementing a Serverless Media-Processing Workflow
SRV328 Designing and Implementing a Serverless Media-Processing WorkflowSRV328 Designing and Implementing a Serverless Media-Processing Workflow
SRV328 Designing and Implementing a Serverless Media-Processing WorkflowAmazon Web Services
 
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...Amazon Web Services
 
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...Chris Munns
 
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...Amazon Web Services
 
Designing and Implementing a Serverless Media Processing Workflow Using AWS S...
Designing and Implementing a Serverless Media Processing Workflow Using AWS S...Designing and Implementing a Serverless Media Processing Workflow Using AWS S...
Designing and Implementing a Serverless Media Processing Workflow Using AWS S...Amazon Web Services
 
Serverless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best PracticesServerless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best PracticesDaniel Zivkovic
 
Thirty Serverless Architectures in 30 Minutes - SRV325 - Chicago AWS Summit
Thirty Serverless Architectures in 30 Minutes - SRV325 - Chicago AWS SummitThirty Serverless Architectures in 30 Minutes - SRV325 - Chicago AWS Summit
Thirty Serverless Architectures in 30 Minutes - SRV325 - Chicago AWS SummitAmazon Web Services
 
AWS Summit Singapore - Lambda, Step Functions and Datadog: A Symphony
AWS Summit Singapore - Lambda, Step Functions and Datadog: A SymphonyAWS Summit Singapore - Lambda, Step Functions and Datadog: A Symphony
AWS Summit Singapore - Lambda, Step Functions and Datadog: A SymphonyAmazon Web Services
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaAmazon Web Services
 
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
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep DiveAmazon Web Services
 
SRV213-Thirty Serverless Architectures in 30 Minutes
SRV213-Thirty Serverless Architectures in 30 MinutesSRV213-Thirty Serverless Architectures in 30 Minutes
SRV213-Thirty Serverless Architectures in 30 MinutesAmazon Web Services
 
2016 - Serverless Microservices on AWS with API Gateway and Lambda
2016 - Serverless Microservices on AWS with API Gateway and Lambda2016 - Serverless Microservices on AWS with API Gateway and Lambda
2016 - Serverless Microservices on AWS with API Gateway and Lambdadevopsdaysaustin
 
Building Advanced Serverless Workflows with AWS Step Functions | AWS Floor28
Building Advanced Serverless Workflows with AWS Step Functions | AWS Floor28Building Advanced Serverless Workflows with AWS Step Functions | AWS Floor28
Building Advanced Serverless Workflows with AWS Step Functions | AWS Floor28Amazon Web Services
 
Working with data using Azure Functions.pdf
Working with data using Azure Functions.pdfWorking with data using Azure Functions.pdf
Working with data using Azure Functions.pdfStephanie Locke
 

Ähnlich wie AWS Lambda Layers, the Runtime API, & Nested Applications (20)

Best Practices and Hard Lessons of Serverless- AWS Startup Day Toronto- Diego...
Best Practices and Hard Lessons of Serverless- AWS Startup Day Toronto- Diego...Best Practices and Hard Lessons of Serverless- AWS Startup Day Toronto- Diego...
Best Practices and Hard Lessons of Serverless- AWS Startup Day Toronto- Diego...
 
End AWS Lambda Cold Starts with Provisioned Concurrency
End AWS Lambda Cold Starts with Provisioned ConcurrencyEnd AWS Lambda Cold Starts with Provisioned Concurrency
End AWS Lambda Cold Starts with Provisioned Concurrency
 
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
 
Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsug
 
SRV328 Designing and Implementing a Serverless Media-Processing Workflow
SRV328 Designing and Implementing a Serverless Media-Processing WorkflowSRV328 Designing and Implementing a Serverless Media-Processing Workflow
SRV328 Designing and Implementing a Serverless Media-Processing Workflow
 
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
 
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...
 
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...
 
Designing and Implementing a Serverless Media Processing Workflow Using AWS S...
Designing and Implementing a Serverless Media Processing Workflow Using AWS S...Designing and Implementing a Serverless Media Processing Workflow Using AWS S...
Designing and Implementing a Serverless Media Processing Workflow Using AWS S...
 
Serverless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best PracticesServerless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best Practices
 
Thirty Serverless Architectures in 30 Minutes - SRV325 - Chicago AWS Summit
Thirty Serverless Architectures in 30 Minutes - SRV325 - Chicago AWS SummitThirty Serverless Architectures in 30 Minutes - SRV325 - Chicago AWS Summit
Thirty Serverless Architectures in 30 Minutes - SRV325 - Chicago AWS Summit
 
AWS Summit Singapore - Lambda, Step Functions and Datadog: A Symphony
AWS Summit Singapore - Lambda, Step Functions and Datadog: A SymphonyAWS Summit Singapore - Lambda, Step Functions and Datadog: A Symphony
AWS Summit Singapore - Lambda, Step Functions and Datadog: A Symphony
 
Taking serverless to the edge
Taking serverless to the edgeTaking serverless to the edge
Taking serverless to the edge
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
 
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
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
 
SRV213-Thirty Serverless Architectures in 30 Minutes
SRV213-Thirty Serverless Architectures in 30 MinutesSRV213-Thirty Serverless Architectures in 30 Minutes
SRV213-Thirty Serverless Architectures in 30 Minutes
 
2016 - Serverless Microservices on AWS with API Gateway and Lambda
2016 - Serverless Microservices on AWS with API Gateway and Lambda2016 - Serverless Microservices on AWS with API Gateway and Lambda
2016 - Serverless Microservices on AWS with API Gateway and Lambda
 
Building Advanced Serverless Workflows with AWS Step Functions | AWS Floor28
Building Advanced Serverless Workflows with AWS Step Functions | AWS Floor28Building Advanced Serverless Workflows with AWS Step Functions | AWS Floor28
Building Advanced Serverless Workflows with AWS Step Functions | AWS Floor28
 
Working with data using Azure Functions.pdf
Working with data using Azure Functions.pdfWorking with data using Azure Functions.pdf
Working with data using Azure Functions.pdf
 

Mehr von 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
 

Mehr von 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
 

AWS Lambda Layers, the Runtime API, & Nested Applications

  • 1. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Pop-up Loft AWS Lambda Layers and the Runtime API Chris Munns Principal Developer Advocate AWS Serverless
  • 2. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved About me: Chris Munns - munns@amazon.com, @chrismunns – Principal 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. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved https://secure.flickr.com/photos/mgifford/4525333972 Why are we here today?
  • 4. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
  • 5. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Serverless applications Services (anything) Changes in data state Requests to endpoints Changes in resource state Event source Function Node.js Python Java C# Go Ruby Runtime API
  • 6. © 2019, 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, more) public String handleRequest(Book book, Context context) { saveBook(book); return book.getName() + " saved!"; }
  • 7. Anatomy of a Lambda function Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here }
  • 8. Anatomy of a Lambda function Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Functions will then grow in complexity with business logic sub-functions
  • 9. Anatomy of a Lambda functionImport sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Business logic sub-functions
  • 10. Anatomy of a Lambda functionImport sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions
  • 11. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Anatomy of a serverless application Amazon API Gateway /orders /forums /search /lists /user /... Now assume that I have an API based workload
  • 12. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Anatomy of a serverless application Databases/ Data stores AWS Secrets Manager / AWS Parameter Store It needs to read/write to a DB and get keys and configuration from external services
  • 13. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Anatomy of a serverless application Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Amazon API Gateway /orders /forums /search /lists /user /... Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Databases/ Data stores AWS Secrets Manager / AWS Parameter Store
  • 14. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Anatomy of a serverless application Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Amazon API Gateway /orders /forums /search /lists /user /... Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Pre-handler-secret-getter() { } Function Pre-handler-db-connect(){ } Function subFunctionA(thing){ ## logic here } Function subFunctionA(thing){ ## logic here } Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions Databases/ Data stores AWS Secrets Manager / AWS Parameter Store There could be a lot of duplicated code here!
  • 15. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Anatomy of a serverless application Amazon API Gateway /orders /forums /search /lists /user /... Databases/ Data stores AWS Secrets Manager / AWS Parameter Store Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Import sdk Import http-lib Import ham-sandwich Pre-handler-secret-getter() Pre-handler-db-connect() Function myhandler(event, context) { <Event handling logic> { result = SubfunctionA() }else { result = SubfunctionB() return result; } Function Dependencies, configuration information, common helper functions Common helper functions Business logic sub-functions We want something more like this:
  • 16. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Lambda Layers Lets functions easily share code: Upload layer once, reference within any function Layer can be anything: dependencies, training data, configuration files, etc Promote separation of responsibilities, lets developers iterate faster on writing business logic Built in support for secure sharing by ecosystem
  • 17. © 2019, 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 • You can reference up to five layers, one of which can optionally be a custom runtime 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
  • 18. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved How Lambda Layers Work • Order is important because each layer is a ZIP file, and they are all extracted in the same path – /opt – Each layer can potentially overwrite the previous one • This approach can be used to customize the environment – For example, the first layer can be a custom runtime and the second layer adds specific versions of the libraries you need • The storage of your Lambda Layers takes part in the AWS Lambda Function storage per region limit (75GB)
  • 19. © 2019, 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)
  • 20. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Lambda Layers Permissions • Layers can be used within – An AWS account – Shared between accounts – Shared publicly with the broad developer community • AWS published a public layer which includes NumPy and SciPy, two popular scientific libraries for Python – This prebuilt and optimized layer can help you start very quickly with data processing and machine learning applications • More from AWS coming!
  • 21. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved DEMO!
  • 22. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved
  • 23. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved AWS Lambda wants to make it easy for developers to get started writing applications without needing to worry about installing software on servers or in containers
  • 24. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Managing the language runtimes for our customers helps make it easier to do this!
  • 25. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Currently supported languages and versions • Node.js 6.10 • Node.js 8.10 • Python 2.7 • Python 3.6 • Python 3.7 • Go 1.x • Ruby 2.5 • Java 8 • .Net Core 1.0 (C#) • .Net Core 2.0 (C#) • .Net Core 2.1 (C#/PowerShell)
  • 26. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Currently supported languages and versions • Node.js 6.10 • Node.js 8.10 • Python 2.7 • Python 3.6 • Python 3.7 • Go 1.x • Ruby 2.5 • Java 8 • .Net Core 1.0 (C#) • .Net Core 2.0 (C#) • .Net Core 2.1 (C#/PowerShell) These represent the majority of what our customers are writing applications in today...
  • 27. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved But there’s a long longtail of other languages.. • The Stack Overflow “Developer Survey” from 2018 mentioned 25 different languages (without versions) used by developers. • https://insights.stackoverflow.com/survey/2018 • GitHub’s 2018 “State of the Octoverse” report lists a top 10 as well as top 10 growing languages including languages such as: Rust, Groovy, and Kotlin. • https://octoverse.github.com/projects From Stack Overflow Developer Survey 2018
  • 28. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved But there’s a long longtail of other languages.. • The Stack Overflow “Developer Survey” from 2018 mentioned 25 different languages (without versions) used by developers. • https://insights.stackoverflow.com/survey/2018 • GitHub’s 2018 “State of the Octoverse” report lists a top 10 as well as top 10 growing languages including languages such as: Rust, Groovy, and Kotlin. • https://octoverse.github.com/projects From Stack Overflow Developer Survey 2018 Customers care about these, and we care about you.
  • 29. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Lambda Custom Runtimes Bring any Linux compatible language runtime Powered by new Runtime API - Codifies the runtime calling conventions and integration points At launch, custom runtimes powering Ruby support in AWS Lambda, more runtimes from partners (like Erlang) Custom runtimes distributed as “layers” Rule Stack
  • 30. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Lambda Runtime API • You can now select a custom runtime in the console (provided in the API/SDKs/CLI) as the runtime of a Lambda function • With this selection, 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 • Your code can use any programming language
  • 31. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Runtime Bootstrap • The bootstrap executable acts 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
  • 32. © 2019, 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
  • 33. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Lambda Runtime API - Processing Tasks 1. Get an event 2. Propagate tracing ID 3. Create a context object 4. Invoke the function handler 5. Handle the response 6. Handle errors 7. Cleanup
  • 34. © 2019, 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
  • 35. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Using Custom Runtimes • For the execution of your code, you can use anything that can run in the Lambda execution environment. – For example, you can bring an interpreter for the programming language of your choice. • You only need to know how the Runtime API works if you want to manage or publish your own runtimes • As a developer, you can quickly use runtimes that are shared with you as layers – Custom runtimes can be shared as layers so that developers can pick them up and use their favorite programming language when authoring Lambda functions
  • 36. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved New: Open Source Runtimes AWS OPEN SOURCE PARTNER SUPPORTED o f f e r e d b y o f f e r e d b y o f f e r e d b y o f f e r e d b y Can find more here: https://github.com/mthenw/awesome-layers !
  • 37. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Stackery’s PHP Lambda Layer
  • 38. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved DEMO!
  • 39. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved aws.amazon.com/serverless
  • 40. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved Chris Munns munns@amazon.com @chrismunnshttps://www.flickr.com/photos/theredproject/3302110152/
  • 41. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved ? https://secure.flickr.com/photos/dullhunk/202872717/