(events): fails to attach more than one Lambda to EventBridge trigger
See original GitHub issuedescription of the bug: When adding multiple Lambda targets to EventBridge Rule, it only adds the trigger source to the first Lambda and it fails to properly add the trigger source to the other Lambdas. This behavior was first witnessed around 11/7-11/8/2020 and was working fine before then.
Reproduction Steps
import aws_cdk.aws_events as ev
import aws_cdk.aws_events_targets as evt
import aws_cdk.aws_lambda as lambda_
import aws_cdk.core as core
class TestStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# event bus
event_bus = ev.EventBus(
self,
id="event_bus_id",
event_bus_name="test_event_bus"
)
# event rule
event_bus_rule = ev.Rule(
self,
id="event_bus_rule_id",
event_bus=event_bus,
rule_name="test_event_rule"
)
# lambda to trigger bus
fn_0 = lambda_.Function(
self,
id="fn_0_id",
code=lambda_.InlineCode("def lambda_handler(event, context): pass"),
handler="index.lambda_handler",
runtime=lambda_.Runtime.PYTHON_3_7,
function_name="test_fn_0"
)
# event pattern for bus
event_bus_rule.add_event_pattern(
account=[self.account],
resources=[fn_0.function_arn + ":$LATEST"]
)
# lambda 1 to be triggered
fn_1 = lambda_.Function(
self,
id="fn_1_id",
code=lambda_.InlineCode("def lambda_handler(event, context): pass"),
handler="index.lambda_handler",
runtime=lambda_.Runtime.PYTHON_3_7,
function_name="test_fn_1"
)
# adding lambda 1 as target
event_bus_rule.add_target(evt.LambdaFunction(fn_1))
# lambda 2 to be triggered
fn_2 = lambda_.Function(
self,
id="fn_2_id",
code=lambda_.InlineCode("def lambda_handler(event, context): pass"),
handler="index.lambda_handler",
runtime=lambda_.Runtime.PYTHON_3_7,
function_name="test_fn_2"
)
# adding lambda 2 as target
event_bus_rule.add_target(evt.LambdaFunction(fn_2))
What did you expect to happen?
- Create EventBridge and Rule with Event pattern
- Lambda 0 to trigger rule with event pattern
- EventBridge to create Targets for Lambdas 1 and 2
- Attach trigger to Lambdas 1 and 2
What actually happened?
- Created EventBridge and Rule with Event pattern
- Lambda 0 to trigger rule with event pattern
- EventBridge created Targets for Lambdas 1 and 2
- EventBridge attached trigger to Lambda 1
- EventBridge failed to attach trigger to Lambda 2
Environment
- CDK CLI Version : 1.77.0
- Framework Version: 1.77.0
- Node.js Version: 12.14.0
- OS: Mac 11.0.1 (Big Sur)
- Language (Version): Python (3.7.5)
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Why wasn't my Lambda function triggered by my EventBridge ...
I created an Amazon EventBridge rule using the AWS Command Line ... Events can be retrieved from the DLQ and analyzed to obtain...
Read more >Is it possible to trigger AWS Lambda Function by Event Bridge ...
But the payload to the Lambda function has an array of events (though usually with only one event in it). If there are...
Read more >Why wasn't my Lambda function triggered by my ... - YouTube
For more details see the Knowledge Center article with this video: https://aws.amazon.com/premiumsupport... Napoleone shows you why your ...
Read more >Triggering all active Lambda instances every min - AWS re:Post
However, it would simply call one of the instances (the routing strategy is ... in EventBridge) to configure a broadcast event to trigger...
Read more >13 AWS Lambda design considerations you need to know about
This is most probably one of the most important considerations: how a Lambda fails and retries is based on the invocation type. For...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Agreed #11217 with v1.72 looks like it. That release was around the same time when it got hit. Thanks for the prompt response @shivlaks !
was this behaviour observed with an upgrade to
1.77.0
? - do you know the previous version where it was working? Since this might be a regression, classifying it as ap1
so we can prioritize getting a fix out.