-
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
chore(lambda-nodejs): do not add unused environment variable by default for sdk v3 lambda runtimes #30117
Conversation
when working with the AWS SDK for JavaScript. Set the `awsSdkConnectionReuse` prop to `false` to disable it. | ||
when working with the AWS SDK v2 for JavaScript. Set the `awsSdkConnectionReuse` prop to `false` to disable it. | ||
|
||
The AWS SDK v3 for JavaScript does not include the environment variable set by `awsSdkConnectionReuse`. See [this guide](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-reusing-connections.html) for information about reusing connections. Therefore, for runtimes >= Node 18, which include SDK v3, the prop defaults to `false`, and must be explicitly set to `true` in order for the environment variable to be set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would setting it to true do anything in sdk v3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the property does not exist. I believe it has no effect whatsoever.
@@ -43,15 +43,19 @@ export interface NodejsFunctionProps extends lambda.FunctionOptions { | |||
readonly runtime?: lambda.Runtime; | |||
|
|||
/** | |||
* The `AWS_NODEJS_CONNECTION_REUSE_ENABLED` environment variable does not exist in the AWS SDK for JavaScript v3. | |||
* | |||
* This prop will be deprecated when the Lambda Node16 runtime is deprecated on June 12, 2024. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add a @see and the link to where this deadline is mentioned
Annotations.of(scope).addWarningV2('aws-cdk-lib/aws-lambda-nodejs:unusedSdkEvironmentVariable', 'The AWS_NODEJS_CONNECTION_REUSE_ENABLED environment variable does not exist in SDK v3. You have explicitly set `awsSdkConnectionReuse`; please make sure this is intentional.'); | ||
this.addEnvironment('AWS_NODEJS_CONNECTION_REUSE_ENABLED', '1', { removeInEdge: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this env variable do anything in sdk v3? Is this for backward compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left this so users can set it if need be (they can also configure their environment variables directly). I figured some users may define >= Node 18 runtimes, but bundle the sdk v2 into their v2 handlers, and this would be for ease of use / backwards compatibility.
@Mergifyio update |
✅ Branch has been successfully updated |
@Mergifyio update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job!
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
…lt for sdk v3 lambda runtimes (aws#30117) Closes aws#29497 Related to aws#29538 ### Reason for this change The `AWS_NODEJS_CONNECTION_REUSE_ENABLED` does not exist in SDK v3. Including it in the environment can add to cold start times. ### Description of changes For Lambda runtimes >= Node 18, do not set the variable by default. If set explicitly, give the user a warning. We can plan to simplify this logic & deprecate the property after we deprecate Node 16 and remove it as the default runtime for this construct. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…lt for sdk v3 lambda runtimes (aws#30117) Closes aws#29497 Related to aws#29538 ### Reason for this change The `AWS_NODEJS_CONNECTION_REUSE_ENABLED` does not exist in SDK v3. Including it in the environment can add to cold start times. ### Description of changes For Lambda runtimes >= Node 18, do not set the variable by default. If set explicitly, give the user a warning. We can plan to simplify this logic & deprecate the property after we deprecate Node 16 and remove it as the default runtime for this construct. ---- *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. If you need help, please open a new issue that references this one. |
Closes #29497
Related to #29538
Reason for this change
The
AWS_NODEJS_CONNECTION_REUSE_ENABLED
does not exist in SDK v3. Including it in the environment can add to cold start times.Description of changes
For Lambda runtimes >= Node 18, do not set the variable by default. If set explicitly, give the user a warning.
We can plan to simplify this logic & deprecate the property after we deprecate Node 16 and remove it as the default runtime for this construct.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license