AWS Lambda Now Supports Custom Runtimes and Enables Sharing Common Code Between Functions

Posted on: Nov 29, 2018

We are announcing Lambda Runtime API and Lambda Layers, two new AWS Lambda features that enable developers to build custom runtimes, and share and manage common code between functions. 

Lambda makes it easy for developers to run code for virtually any type of application or backend service - all with zero administration. The Runtime API for AWS Lambda defines a standardized HTTP-based specification which codifies how Lambda and a function’s runtime communicate. It enables you to build custom runtimes that integrate with Lambda to execute functions in response to events. By leveraging the Runtime API, you can use binaries or shell scripts, and your choice of programming languages and language versions. Getting started with Runtime API is simple. When deploying your function using the Lambda management console or CLI, specify that you are providing your own runtime. During an invoke, Lambda will bootstrap your runtime code and communicate with it over Runtime API to execute the function code. With this release, we are also publishing a reference implementation of the C++ and Rust runtimes. You can read more about the Runtime API in the Lambda documentation.

Lambda Layers are a new type of artifact that can contain arbitrary code and data, and may be referenced by zero, one, or more functions at the same time. Lambda functions in a serverless application typically share common dependencies such as SDKs, frameworks, and now runtimes. With layers, you can centrally manage common components across multiple functions enabling better code reuse. To use layers, you simply put your common code in a zip file, and upload it to Lambda as a layer. You then configure your functions to reference it. When a function is invoked, the layer contents become available to your function code. We are also providing a layer which includes the popular NumPy and SciPy scientific libraries for Python. These libraries were prebuilt and optimized for use in Lambda’s execution environment. By using this layer with your Python functions, you can quickly get started with building complex data processing and machine learning applications. Read more about Lambda Layers in the AWS Lambda documentation.

Runtime API and Layers can be used independently. You can also use them together to publish custom runtimes which can be then shared as layers. You can also use the AWS Serverless Application Model (SAM) and SAM CLI to test, deploy and manage serverless applications that leverage Runtime API and Layers. 

With this release, several of our technology partners are also launching their offerings on top of Runtime API and Layers. Customers can author functions in new runtimes and layers, including those which support additional capabilities including application management, monitoring, and security. To learn more, visit the AWS Lambda partners page.

Runtime API and Layers can be used in all regions where Lambda is available. For more information on where AWS Lambda is available, see the AWS region table. Please visit our product page for more information about AWS Lambda or log in to the AWS Lambda console to get started.