Skip to content

AWS CDK sample project that demonstrates how to use Lambda layers for NPM dependencies.

Notifications You must be signed in to change notification settings

ryparker/aws-cdk-sample-lambda-layers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS CDK Sample Lambda Layers Project

This project creates two stacks. One stack creates a LambdaLayerVersion that hold the NPM dependency chalk. The other stack creates a new LambdaFunction that uses the layer's chalk dependency to print "Hello World!".

Notice: There are known CloudFormation limitations when using Lambda layers across multiple stacks. To workaround this problem, we create the Lambda layer stack first and store the created Lambda Layer's ARN in SSM parameter store. We then deploy the Lambda function stack which imports that Layer ARN from SSM parameter store. This allows users to update the configuration of the Lambda Layer without running into the dependency error:

Error: someResource cannot be updated as it is in use by otherResource

For other workarounds checkout this issue thread.

🚀 Quick Start

1. Install dependencies with Yarn v1

  yarn install

2. Create the bootstrap stack in your AWS account This only needs to be ran once per account/region.

  yarn bootstrap

3. Build Cloudformation files

  yarn build

4. Deploy the Lambda Layer stack

  yarn deploy LambdaLayerStack

5. Deploy the Lambda Function stack

  yarn deploy LambdaFunctionStack

About

AWS CDK sample project that demonstrates how to use Lambda layers for NPM dependencies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published