-
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
Change Custom Resource mechanism to make Lambda explicit #35
Change Custom Resource mechanism to make Lambda explicit #35
Conversation
Introducing `SingletonLambda` which can be instantiated multiple times but only adds the Lambda to the underlying stack once. A CustomResource now explicitly takes either a `LambdaRef` or a `TopicRef`, and the Lambda can be a SingletonLambda. This splitting up makes it possible to establish bidirectional permissions between the Custom Resource Lambda and other resources.
The inevitable question here is going to be, "why is SingletonLambda in |
constructor(parent: Construct, name: string, props: SingletonLambdaProps) { | ||
super(parent, name); | ||
|
||
this.lambdaFunction = this.ensureLambda(slugify(props.uuid), props); |
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'd call slugify
inside ensureLambda
(especially given the name of the param is uuid
).
Also, #12
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 mean, yeah, but that's not done yet, so neither is this :)
this.functionName = this.lambdaFunction.functionName; | ||
this.role = this.lambdaFunction.role; | ||
|
||
this.canCreatePermissions = true; // Doesn't matter, addPermission is overriden anyway |
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.
So why do we need to specify?
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.
Because it's abstract in the parent.
Introducing
SingletonLambda
which can be instantiated multiple timesbut only adds the Lambda to the underlying stack once.
A CustomResource now explicitly takes either a
LambdaRef
or aTopicRef
,and the Lambda can be a SingletonLambda.
This splitting up makes it possible to establish bidirectional permissions
between the Custom Resource Lambda and other resources, as discussed in #9.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.