-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lambda-layers): add AWS SDK JS layer #5077
Conversation
Add a new package `@aws-cdk/lambda-layers` that offers pre-built layers. Layer building is currently only supported for Node.js and works as follows: * List static members of the `Layer` class (= layers to build) * Create a dummy `package.json` file containing only dependencies for this layer in the `layers` folder. Dependencies versions are extracted from the `package.json` of `@aws-cdk/lambda-layers`. * Run `npm install` As layer dependencies are extracted from the main `package.json` they can be picked up by `dependabot`, automatically updating the layer when needed. The `getLayerVersion()` method returns a singleton `lambda.LayerVersion` that can be used in Lambda functions. The first layer is `AWS_SDK_JS` which offers a more recent version of the AWS SDK than the one included in the Lambda runtime (it will also be updated more frequently). Use the `AWS_SDK_JS` layer in `AwsCustomResource` and `AwsApi` event target. Closes aws#2689 Closes aws#5063
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This looks like something that would make it much easier to implement utility lambdas like the one I made for handling the ECR image scan results (https://github.com/markusl/ecr-image-scan-result-handler-lambda). I can see that after these changes, the functionality could be implemented directly as CDK Custom Resource, if I understand the PR correctly. Thanks for implementing this @jogold :) |
@jogold, as usual, creative and interesting and definitely something I'd like to look into. Due to re:Invent coming up very soon, I am not sure I'll be able to give this the needed attention. I'll try but can't promise. It's on my radar and the direction is super interesting. Two quick observations:
|
SAR applications could be a solution, there is a similar discussion in #3797. The first step could be to develop a L2 construct for this maybe? This means that you would have a CDK app within the CDK repo Also, I'm facing issues with the integ tests here: when a new version of the aws-sdk is released dependabot will open a PR but the source hash of the layer will change, meaning that someone will have to manually update the PR to update the integ tests where this layer is used... |
Related: aws/aws-sdk-js#2528 |
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
5 similar comments
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Close in favor of #5442 that tries to solve the same problem? Offering pre-built layers can still be interesting though. |
Ok, closing for now. I agree that this is definitely an interesting area to explore. |
Add a new package
@aws-cdk/lambda-layers
that offers pre-built layers.Layer building is currently only supported for Node.js and works as follows:
Layer
class (= layers to build)package.json
file containing only dependencies for this layerin the
layers
folder. Dependencies versions are extracted from thepackage.json
of
@aws-cdk/lambda-layers
.npm install
As layer dependencies are extracted from the main
package.json
they can be pickedup by
dependabot
, automatically updating the layer when needed.The
getLayerVersion()
method returns a singletonlambda.LayerVersion
that can beused in Lambda functions.
The first layer is
AWS_SDK_JS
which offers a more recent version of the AWS SDK thanthe one included in the Lambda runtime (it will also be updated more frequently).
Use the
AWS_SDK_JS
layer inAwsCustomResource
andAwsApi
event target.Closes #2689
Closes #5063
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license