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

fix(lambda-nodejs): remove smithy models from bundling for AWS SDK v3 runtimes (under feature flag) #31639

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

GavinZZ
Copy link
Contributor

@GavinZZ GavinZZ commented Oct 3, 2024

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


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Oct 3, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team October 3, 2024 19:27
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 3, 2024
@GavinZZ GavinZZ marked this pull request as ready for review October 3, 2024 19:59
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Oct 3, 2024
@xazhao
Copy link
Contributor

xazhao commented Oct 3, 2024

The code LGTM. Just curious what will customers see when there's version mismatch?

Copy link
Contributor

mergify bot commented Oct 3, 2024

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).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Oct 3, 2024
Copy link
Contributor

mergify bot commented Oct 3, 2024

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).

@GavinZZ
Copy link
Contributor Author

GavinZZ commented Oct 3, 2024

The code LGTM. Just curious what will customers see when there's version mismatch?

One quick example I can think of if there's a mismatch in version and customer used a newer method in a newer @aws-sdk/* library but with an older @smithy/* library would be TypeError: mySdk.someNewMethod is not a function

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 7428f07
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 19ee46d into main Oct 3, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Oct 3, 2024

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).

@mergify mergify bot deleted the remove_smithy_from_bundling branch October 3, 2024 22:53
Copy link

github-actions bot commented Oct 3, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-lambda-nodejs): treat @smithy scope identically to @aws-sdk scope if excluding packages
3 participants