Speed-up Lambda function deployment with dependency layers built in AWS
Project description
Turbo Layers for CDK
Speed up deployment of Lambda functions by creating dependency layers in AWS instead of locally.
- Easily separate dependency deployment from Lambda code deployment
- Never re-package dependencies just because of a small code change
- Never download another single dependency package locally again
- Never upload oversized code packages again
- Edit your code in the browser -- no more "deployment package too large to enable inline code editing" errors
- Uninstall Docker from your laptop and extend your battery life
- Take shorter coffee breaks when deploying
Supported Lambda runtimes:
- Python
- Node.js
- Ruby
API
The best way to browse API documentation is on Constructs Hub. It is available in all supported programming languages.
Installation
-
Confirm you're using CDK v2
-
Install the appropriate package
-
pip install cloudsnorkel.cdk-turbo-layers
-
npm i @cloudsnorkel/cdk-turbo-layers
-
<dependency> <groupId>com.cloudsnorkel</groupId> <artifactId>cdk.turbo-layers</artifactId> </dependency>
-
go get github.com/CloudSnorkel/cdk-turbo-layers-go/cloudsnorkelcdkturbolayers
-
dotnet add package CloudSnorkel.Cdk.TurboLayers
-
Example
const packager = new PythonDependencyPackager(this, 'Packager', {
runtime: lambda.Runtime.PYTHON_3_9,
type: DependencyPackagerType.LAMBDA,
});
new Function(this, 'Function with inline requirements', {
handler: 'index.handler',
code: lambda.Code.fromInline('def handler(event, context):\n import requests'),
runtime: lambda.Runtime.PYTHON_3_9,
// this will create a layer from with requests and Scrapy in a Lambda function instead of locally
layers: [packager.layerFromInline('inline requirements', ['requests', 'Scrapy'])],
});
new Function(this, 'Function with external source and requirements', {
handler: 'index.handler',
code: lambda.Code.fromAsset('lambda-src'),
runtime: lambda.Runtime.PYTHON_3_9,
// this will read pyproject.toml and poetry.lock and create a layer from the requirements in a Lambda function instead of locally
layers: [packager.layerFromPoetry('poetry requirements', 'lambda-src')],
});
Older Implementations
- lovage: standalone Python framework that uses the same trick to deploy decorated functions to AWS
- serverless-pydeps: plugin for Serverless Framework that speeds up deployment
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for cloudsnorkel.cdk-turbo-layers-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60eb1c8c0123b5466914600bb7fbf8aa6918c4f29633b21426ed249f287e514a |
|
MD5 | 8653af5d787dd57eec9a10a39dc9b896 |
|
BLAKE2b-256 | ab5dc9217f0e601d5b3ba6e8da936946eb02e66d595713f521da8a33b4021f3c |
Close
Hashes for cloudsnorkel.cdk_turbo_layers-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efe2db5a9053dcf876757c221b3fc689c5ee5446ee9d6f8f856e7b285d50e5ad |
|
MD5 | ddf2092858e1977faf0344a4c8af79e6 |
|
BLAKE2b-256 | 37e90b3d173d978a110b479acdca4a9c0e9ad35691bb211ed04dbd198f702060 |