fix(lambda-nodejs): support bundling aws-sdk as part of the bundled code asset#29207
fix(lambda-nodejs): support bundling aws-sdk as part of the bundled code asset#29207mergify[bot] merged 5 commits intoaws:mainfrom
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
I like the proposal, but I think calling the option |
| // Create dummy package.json, copy lock file if any and then install | ||
| depsCommand = chain([ | ||
| isPnpm ? osCommand.write(pathJoin(options.outputDir, 'pnpm-workspace.yaml'), ''): '', // Ensure node_modules directory is installed locally by creating local 'pnpm-workspace.yaml' file | ||
| isPnpm ? osCommand.write(pathJoin(options.outputDir, 'pnpm-workspace.yaml'), '') : '', // Ensure node_modules directory is installed locally by creating local 'pnpm-workspace.yaml' file |
There was a problem hiding this comment.
[nit] : Is the space intentional? It is there at couple of places in this file.
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
GavinZZ
left a comment
There was a problem hiding this comment.
Looks good, thanks for contributing!
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
@jonife Wouldn't this be a breaking change for those who included the AWS SDK by setting |
Issue # (if applicable)
#25492.
Closes #.
#25492.
Reason for this change
The BundlingOptions in NodejsFunction construct removes AWS SDK dependencies by default.
This uses Lambda Provided SDK in the resulting function. This has higher cold start than a bundled function with AWS SDK dependencies included.
This happens, because the Node.js runtime has to do module resolution and go through multiple files while reading dependency code in the bundled function which uses Lambda Provided SDK. When SDK in bundled with the function code, the cold starts are lower as the as Node.js runtime has to read single file without any module resolution.
Result from reproduction:
{
'NodejsFunction default (uses Lambda Provided SDK)': 1227.1435,
'NodejsFunction custom (uses Customer Deployed SDK)': 929.441
}
related to this issue: #25492
Description of changes
While maintaining backward compatibility, an new option
useAwsSDKwas introduced to include the sdk in the code assetyes kindly refer to the above
Description of how you validated changes
Added both unit and integration test
yes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license