-
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
docs(lambda-nodejs): Add note on usage as lambda@edge #9453
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Thanks.
The long term solution is what @eladb described in #9328 (comment) (detection of edge usage for a Lambda and removal of env vars with warning)
Implementing something like what @eladb proposed seems best, but meanwhile updating the documentation might work as a stop-gap solution. |
@@ -43,6 +43,7 @@ All other properties of `lambda.Function` are supported, see also the [AWS Lambd | |||
|
|||
The `NodejsFunction` construct automatically [reuses existing connections](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html) | |||
when working with the AWS SDK for JavaScript. Set the `awsSdkConnectionReuse` prop to `false` to disable it. | |||
This must be disabled when the function is meant to be used as a lambda@edge. |
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.
Is it possible to identify that this lambda is used as Lambda@Edge and make the default smarter?
@jogold, any ideas?
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.
Yes this is #9562, specifically this line https://github.com/jogold/aws-cdk/blob/1ce04e197bab5f116a3cec641f83f74844bb1f00/packages/%40aws-cdk/aws-lambda-nodejs/lib/function.ts#L88. #9562 is marked to close this PR.
…@edge (#9562) Check version and function compatibility when a Lambda is used for Lambda@Edge. Environment variables can be marked as "removable" when used for Lambda@Edge. Closes #9328 Closes #9453 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…@edge (aws#9562) Check version and function compatibility when a Lambda is used for Lambda@Edge. Environment variables can be marked as "removable" when used for Lambda@Edge. Closes aws#9328 Closes aws#9453 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Great to see that this is no longer needed 👍 |
By default, lambda functions created using
aws-lambda-nodejs
enable connection reuse by setting the environment variableAWS_NODEJS_CONNECTION_REUSE_ENABLED
to1
. This makes it so that these functions can't be used inside a cloudfront distribution as lambda@edge, because these don't support environment variables.This PR just documents that by adding a note on this in the documentation.
Another possible solution would be to enable connection reuse by changing the config of the aws-sdk agent as shown here. To be honest, I'm not sure which solution is best, as it seems that this second solution might require a modification to the bundling process.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license