Skip to main content

Speed-up Lambda function deployment with dependency layers built in AWS

Project description

Turbo Layers for CDK

NPM PyPI Maven Central Go Nuget License

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

  1. Confirm you're using CDK v2

  2. Install the appropriate package

    1. Python

      pip install cloudsnorkel.cdk-turbo-layers
      
    2. TypeScript or JavaScript

      npm i @cloudsnorkel/cdk-turbo-layers
      
    3. Java

      <dependency>
      <groupId>com.cloudsnorkel</groupId>
      <artifactId>cdk.turbo-layers</artifactId>
      </dependency>
      
    4. Go

      go get github.com/CloudSnorkel/cdk-turbo-layers-go/cloudsnorkelcdkturbolayers
      
    5. .NET

      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.layerFromInline('poetry requirements', 'lambda-src')],
});

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudsnorkel.cdk-turbo-layers-0.0.0.tar.gz (129.0 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page