Event Rule with Target creates circular reference.
Describe the bug When creating a event rule, with pattern and target, the target's source arn is generated with rule's arn. Thus creating a circular reference.
To Reproduce Create a function, create an event, create a pattern and register both to the event. The resulting cloudformation has the circular reference. The target's arn can't be overwritten to use the correct arn. Synth result:
Type: AWS::Events::Rule
Properties:
EventPattern:
detail:
- '{"State":["running","shutting-down","stopped"]}'
detail-type:
- EC2 Instance State-change Notification
id:
- eventPatternForLambda
region:
- us-west-1
source:
- aws.ec2
State: ENABLED
Targets:
- Arn:
Fn::GetAtt:
- MyLambdaCfnEventRuleF85763DB
- Arn
Id: StackLambdaDDNSMyLambdaCfnEventRule7AA3E130
MyLambdaCfnEventRuleF85763DB:
Type: AWS::Events::Rule
Properties:
EventPattern:
detail:
- '{"State":["running","shutting-down","stopped"]}'
detail-type:
- EC2 Instance State-change Notification
id:
- eventPatternForLambda
region:
- us-west-1
source:
- aws.ec2
State: ENABLED
Targets:
- Arn:
Fn::GetAtt:
- MyLambdaCfnEventRuleF85763DB
- Arn
Id: StackLambdaDDNSMyLambdaCfnEventRule7AA3E130
Expected behavior
The Arn on the Target should be the ARN of the function defined in the code. Version: 0.29.0
The bug comes from line 121 in rule.ts in aws-events module.
const targetProps = target.asEventRuleTarget(this.ruleArn, this.node.uniqueId);
As a side thing - you'll find the synth output will display properly if you use a ``` instead of `
As it stands, it's not really easy to parse when trying to understand the bug.
Thanks 👍
I don't think this is still relevant.
Closing, please reopen if I am wrong.