-
Notifications
You must be signed in to change notification settings - Fork 4k
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): treat @smithy
scope identically to @aws-sdk
scope if excluding packages
#31610
Comments
@smithy
scope identically to @aws-sdk
scope@smithy
scope identically to @aws-sdk
scope if excluding packages
@kuhe Thank you. We'll bring this up to the team immediately. |
Thanks for creating this issue. We had a team discussion and we believe this is a valid issue and I'll kick off a PR to fix this issue. |
Discussed with @kuhe offline, and here's the update. ContextNode 16 or below would by default use AWS SDK v2 and Lambda provides the SDK by default so CDK removed Similarly for Node 18+ runtimes, since AWS Lambda includes AWS SDK v3 by default, and CDK excludes all the The mismatch can happen in the following scenarios. This is a pretty edge case but customers did encounter this issue.
The reason that we don't need to remove Proposed SolutionsThere are two solutions to the issue.
|
… runtimes (under feature flag) (#31639) ### Issue # (if applicable) Closes #31610 ### Reason for this change for Node 18+ runtimes, since AWS Lambda includes AWS SDK v3 by default, and CDK excludes all the `@aws-sdk/*` packages because they’re expected to already be present. However, the CDK currently removes only the `@aws-sdk/*` packages when bundling for Node 18+ runtimes, but it does not remove the `@smithy/*` packages. This can cause a mismatch in versions between the `@smithy/*` packages and the AWS SDK packages that AWS Lambda provides. The mismatch can happen in the following scenarios. This is a pretty edge case but customers did encounter this issue. ``` /user-app/node_modules/ - /@smithy/* (v123) <-- this gets used because it wasn't deleted - /@aws-sdk/* (v123) <-- CDK removes `@aws-sdk/*` currently /lambda-hidden-folder/node_modules - /@smithy/* (v456) - /@aws-sdk/* (v456) <-- this gets used as fallback since the module is removed from node_modules by CDK ``` ### Description of changes Add a feature flag. When feature flag is set to true, we will also remove smithy models. ### Description of how you validated changes Added unit tests and integration tests. ### Checklist - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Comments on closed issues and PRs are hard for our team to see. |
Describe the bug
In this readme section, https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda-nodejs/README.md#externals, it states that
However, the core runtime of the AWS SDK for JavaScript (v3) is contained in the scope
@smithy/*
as can be seen in e.g. client-s3/package.json. If a user application has a certain version of the AWS SDK with both core runtime@smithy/
and AWS packages under@aws-sdk/
, deleting only the@aws-sdk/
packages can create a fatal version mismatch between the two sets of dependencies.From the AWS SDK team's perspective, we recommend that the SDK is not removed from user applications due to the AWS Lambda provided SDK having an unpredictable version update cadence. A sudden change in version not initiated by the user may cause errors due to changes in behavior even if technically no "breaking" interface changes occur.
However, if continuing to remove the
@aws-sdk
node_modules folder, the@smithy
folder should be treated identically since they are tightly coupled.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
If deleting
@aws-sdk/
folder, also delete@smithy/
folder. Both NPM scopes are fully controlled by AWS teams.Current Behavior
Only
@aws-sdk/
is deleted, causing mismatch between those and the@smithy/
packages.Reproduction Steps
Use
NODEJS_18_X
runtime and bundle the@aws-sdk/client-s3
package as an example.Inspect the node_modules folder for the existence of
@smithy/
packages.Possible Solution
If deleting
@aws-sdk/
folder, also delete@smithy/
folder.Additional Information/Context
No response
CDK CLI Version
n/a
Framework Version
No response
Node.js Version
NODEJS_18_X, possibly others except NODEJS_LATEST
OS
n/a
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: