Skip to content
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

aws-lambda-nodejs: Add support for bundling aws-sdk #28311

Open
2 tasks
spolaka opened this issue Dec 8, 2023 · 2 comments
Open
2 tasks

aws-lambda-nodejs: Add support for bundling aws-sdk #28311

spolaka opened this issue Dec 8, 2023 · 2 comments
Labels
@aws-cdk/aws-lambda-nodejs effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p3

Comments

@spolaka
Copy link

spolaka commented Dec 8, 2023

Describe the feature

NodejsFunction ESBuild by default excludes the aws sdk from the bundle. Excluding the aws sdk by default reduces the package size, but we observed this is adding additional time to load the aws sdk modules at the function runtime.

Sample function that uses aws sdk to read a dynamoDB table during the init phases takes 800ms if the aws sdk is excluded in the bundle and around 400ms if the aws sdk is bundled in the package.

Rightnow, the only option to include aws sdk in the bundle is to use NODEJS_LATEST as the runtome. I would like to request a feature to support an option to include aws sdk with any specific node runtime.

may be some option like

bundling:{
        includeAwsSdk: true, 
}

Use Case

This will reduce the time for the lambda run and thus improve latency and reduce the cost for the lambda function.

Proposed Solution

I would like to request a feature to support an option to include aws sdk with any specific node runtime.

may be some option like

bundling:{
        includeAwsSdk: true, 
}

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.96.0

Environment details (OS name and version, etc.)

macOS 13.6.2

@spolaka spolaka added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 8, 2023
@khushail khushail added needs-review and removed needs-triage This issue or PR still needs to be triaged. labels Dec 8, 2023
@samchungy
Copy link

This is resolved simply by adding externalModules: [], to the bundling options

@spolaka
Copy link
Author

spolaka commented Dec 12, 2023

This is resolved simply by adding externalModules: [], to the bundling options

Yes, I tried the following work arounds, but both has the limitations

  1. Use NODEJS_LATEST as runtime, disadvantage is we can not fully control the version of the Node runtime.
  2. Use externalModules: [], I can not use this when i have external modules that comes through lambda layers.

My proposal to have an attribute to control the inclusion of AWS SDK would not have disadvantages and can be used in all the scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-nodejs effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p3
Projects
None yet
Development

No branches or pull requests

4 participants