fix(event-targets): circular dependency when the lambda target is in a different stack#11217
fix(event-targets): circular dependency when the lambda target is in a different stack#11217mergify[bot] merged 5 commits intomasterfrom
Conversation
…a different stack
The Lambda Permission resource causes a cyclic dependency when the rule
is in a seprate stack from the lambda target for the rule.
(a picture is worth a thousand words)
```
+-------------------+ +---------------+
|Lamda Stack | |Event Stack |
| | | |
| +----------+ | | +------+ |
| | | | | | | |
| | Function |<-----------------+ Rule | |
| | | | | | | |
| +----------+ | | +------+ |
| ^ | | ^ |
| | | | | |
| +-----+------+ | | | |
| | | | | | |
| | Permission +--------------------+ |
| | | | | |
| +------------+ | | |
| | | |
+-------------------+ +---------------+
```
The fix is to move the Permission resource into the event stack instead.
fixes #10942
| expect(stack).toCountResources('AWS::Lambda::Permission', 1); | ||
| }); | ||
|
|
||
| test('lambda handler and cloudwatch event across stacks', () => { |
There was a problem hiding this comment.
Should there also be a test for an imported Rule, as that changes the behavior?
There was a problem hiding this comment.
Why is this any different for imported Rule? Imported Rules also follow the same logic.
There was a problem hiding this comment.
Ah, nevermind. I thought the if (rule instanceof Construct) { was a check against imported rules. But I see that's not the case.
There was a problem hiding this comment.
Imported resources are also a Construct. They inherit Resource which is a subclass of Construct.
The if statement is needed because IRule and Construct don't overlap. But so far there is no case when the Rule will not be a Construct.
|
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 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 master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
The Lambda Permission resource causes a cyclic dependency when the rule
is in a seprate stack from the lambda target for the rule.
(a picture is worth a thousand words)
The fix is to move the Permission resource into the event stack instead.
fixes #10942
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license