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

docs(lambda-nodejs): Add note on usage as lambda@edge #9453

Closed
wants to merge 1 commit into from

Conversation

corollari
Copy link

By default, lambda functions created using aws-lambda-nodejs enable connection reuse by setting the environment variable AWS_NODEJS_CONNECTION_REUSE_ENABLED to 1. 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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 65af534
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Contributor

@jogold jogold left a 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)

@corollari
Copy link
Author

Implementing something like what @eladb proposed seems best, but meanwhile updating the documentation might work as a stop-gap solution.

jogold added a commit to jogold/aws-cdk that referenced this pull request Aug 10, 2020
…at edge

Automatically remove environment variables of a Lambda function when
it's used at edge. A warning is also shown.

Closes aws#9328
Closes aws#9453
jogold added a commit to jogold/aws-cdk that referenced this pull request Aug 10, 2020
…at edge

Automatically remove environment variables of a Lambda function when
it's used at edge. A warning is also shown.

Works with singleton functions.

Closes aws#9328
Closes aws#9453
jogold added a commit to jogold/aws-cdk that referenced this pull request Aug 10, 2020
…at edge

Automatically remove environment variables of a Lambda function when
it's used at edge. A warning is also shown.

Works with singleton functions.

Closes aws#9328
Closes aws#9453
@eladb eladb changed the title docs(aws-lambda-nodejs): Add note on usage as lambda@edge docs(lambda-nodejs): Add note on usage as lambda@edge Aug 19, 2020
@@ -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.
Copy link
Contributor

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?

Copy link
Contributor

@jogold jogold Aug 19, 2020

Choose a reason for hiding this comment

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

@mergify mergify bot closed this in #9562 Aug 19, 2020
mergify bot pushed a commit that referenced this pull request Aug 19, 2020
…@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*
misterjoshua pushed a commit to misterjoshua/aws-cdk that referenced this pull request Aug 19, 2020
…@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*
@corollari
Copy link
Author

Great to see that this is no longer needed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants