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): incorrect SDK v2 warning generated #27014

Conversation

plumdog
Copy link
Contributor

@plumdog plumdog commented Sep 5, 2023

Fixes to remove an incorrectly generated warning when using Node JS runtime <= 16 with NodejsFunction

Closes #26966


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 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. p2 labels Sep 5, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team September 5, 2023 15:41
Comment on lines 894 to 900
Annotations.fromStack(stack).hasNoWarning('*',
'If you are relying on AWS SDK v3 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 18 or higher. [ack: @aws-cdk/aws-lambda-nodejs:sdkV3NotInRuntime]',
);
Annotations.fromStack(stack).hasNoWarning('*',
'If you are relying on AWS SDK v2 to be present in the Lambda environment already, please explicitly configure a NodeJS runtime of Node 16 or lower. [ack: @aws-cdk/aws-lambda-nodejs:sdkV2NotInRuntime]',
);
Copy link
Contributor Author

@plumdog plumdog Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for "does not produce a warning" this way seems very brittle, but I couldn't see a better way from looking at https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Annotations.html.

Guidance welcomed.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@plumdog
Copy link
Contributor Author

plumdog commented Sep 5, 2023

Exemption Request

This fix only changes what warnings are generated, so no changes to integration tests or snapshots required.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Sep 5, 2023
@plumdog plumdog force-pushed the issue-26966-lambda-nodejs-fix-sdk-v2-runtime-warning branch from f2629e4 to 9eea420 Compare September 5, 2023 16:08
@@ -882,6 +882,24 @@ test('bundling with <= Node16 warns when sdk v3 is external', () => {
);
});

test('bundling with <= Node16 does not warn with default externalModules', () => {
const myStack = new Stack(app, 'MyTestStack2');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears that the warnings don't get cleared from the shared stack after each run. This could invalidate some of the other tests in this file, but I decided to just fix it for my new tests, which fail without it.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 5, 2023
@MrArnoldPalmer MrArnoldPalmer added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Sep 5, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 5, 2023 17:34

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Contributor

@MrArnoldPalmer MrArnoldPalmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was literally just working on this with the exact same solution and tests. LGTM! We should indeed move all the other unit tests to use their own unique stack as well.

@mergify
Copy link
Contributor

mergify bot commented Sep 5, 2023

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 merged commit 856b303 into aws:main Sep 5, 2023
15 of 17 checks passed
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 5, 2023
@plumdog plumdog deleted the issue-26966-lambda-nodejs-fix-sdk-v2-runtime-warning branch September 5, 2023 20:15
mikewrighton pushed a commit that referenced this pull request Sep 14, 2023
Fixes to remove an incorrectly generated warning when using Node JS runtime <= 16 with `NodejsFunction`

Closes #26966 

----

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

I'm not sure how can I disable this warning ? I'm using SDK v3 and I don't know how to disable the warning :\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-lambda-nodejs/lib/bundlingts.ts: Missing condition when checking for v2 runtime
4 participants