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

chore(lambda): current version for singleton functions #9892

Merged
merged 3 commits into from
Aug 26, 2020

Conversation

jogold
Copy link
Contributor

@jogold jogold commented Aug 21, 2020

Add currentVersion for singleton functions. This makes it possible to
use them for Lambda@Edge.

To achieve this, make ensureLambda() return a Function and not an IFunction
(which now allows to remove the default implementation of _checkEdgeCompatibilty()
in FunctionBase).

Also remove deprecated calls to addVersion() introduced in #9562.


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

Add `currentVersion` for singleton functions. This makes it possible to
use them for Lambda@Edge.

Also remove deprecated calls to `addVersion()` introduced in aws#9562.
@robertd
Copy link
Contributor

robertd commented Aug 21, 2020

@jogold Will this also allow currentVersion to be called for imported Lambda functions?

@jogold
Copy link
Contributor Author

jogold commented Aug 24, 2020

@jogold Will this also allow currentVersion to be called for imported Lambda functions?

No, but if you're importing you know the version, no?:

lambda.Version.fromVersionArn(this, 'Version', 'arn:aws:lambda:region:account-id:function:function-name:version')

@robertd
Copy link
Contributor

robertd commented Aug 24, 2020

@jogold Yeah I do, but CloudFront construct expects lambda.currentVersion param. #9901

P.S. Sorry for the off-topic discussion.

if (this.lambda instanceof FunctionBase) {
if (this.lambda instanceof Function) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why you've removed the default implementation of _checkEdgeCompatibility() and changed this line.

Why not run _checkEdgeCompatibility() if it is any kind of FunctionBase?

Copy link
Contributor Author

@jogold jogold Aug 25, 2020

Choose a reason for hiding this comment

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

The only reason we needed to implement it at the FunctionBase level was because the singleton function's ensureLambda() was returning an IFunction instead of a Function which is incorrect.

Now that the singleton function is fixed (in terms of typing) we don't need this at the FunctionBase level: we will never check imported functions for edge compatibility.

Copy link
Contributor Author

@jogold jogold Aug 25, 2020

Choose a reason for hiding this comment

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

Actually the fact that the type Function was aliased as LambdaFunction in the singleton-function.ts file made me use FunctionBase in #9562 because when I tried with Function it was referring to a normal function... I could have used Function (LambdaFunction) in #9562 already.

@mergify
Copy link
Contributor

mergify bot commented Aug 26, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify
Copy link
Contributor

mergify bot commented Aug 26, 2020

Thank you for contributing! Your pull request will be updated from master 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 e6db2a0 into aws:master Aug 26, 2020
@jogold jogold deleted the singleton-version branch August 26, 2020 20:50
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