-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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/lib/bundlingts.ts: Missing condition when checking for v2 runtime #26966
Comments
I also encountered this issue and agree with the investigation above that the logic around generating the warning is invalid. Have opened #27014 to attempt to fix and write some tests. |
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*
|
Hi @plumdog, thank you for looking into this issue. I realize my proposed solutions might not be correct in some cases, such that the user specify Runtime.NODEJS_18_X in NodejsFunction, and then follow the warning instruction to add a 'aws-sdk' as external modules -> the warning is still going to be there. Honestly, I am not sure about the wording of this warning. Is it allowed for someone to use Nodejs 18 and request 'aws-sdk' as external modules like my example above? If not, maybe the warning should tell the dev to upgrade their code to use sdk v3. |
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*
Describe the bug
Hi,
I have been receiving weird warnings from aws cdk about nodejs runtime since upgrading to v2.93.
When creating new NodejsFunction, I make sure to pass
runtime: Runtime.NODEJS_16_X
as one of the props. However, I still get this warning: "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".My company requires all cdk deployment to be executed with strict-mode so we can't ignore this warning.
Expected Behavior
No warning raised by cdk because I am specifying Nodejs 16 or lower as instructed
Current Behavior
A warning is raised whenever I create a NodejsFunction with
runtime: Runtime.NODEJS_16_X
Reproduction Steps
Run cdk synth to create following resource:
Possible Solution
I believe this is the code section that cause the warning:
https://github.com/aws/aws-cdk/blob/d6b71adb41cb2cccf30e2301f872806e12ad4a87/packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts#L127C5-L143C1
If someone pass
runtime: Runtime.NODEJS_16_X
and no externalModules provided like my example above-> isV2Runtime is True -> versionedExternals = ['aws-sdk'] -> defaultExternals = ['aws-sdk'] -> externals = ['aws-sdk']
-> the condition
if (externals.includes('aws-sdk'))
on line 140 is true-> warning message displayed
Possible fix: adding more condition to line 140: if (!isV2Runtime && externals.includes('aws-sdk'))
Additional Information/Context
No response
CDK CLI Version
2.93.0
Framework Version
No response
Node.js Version
16
OS
Ubuntu
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: