question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(events): fails to attach more than one Lambda to EventBridge trigger

See original GitHub issue

description 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?

  1. Create EventBridge and Rule with Event pattern
  2. Lambda 0 to trigger rule with event pattern
  3. EventBridge to create Targets for Lambdas 1 and 2
  4. Attach trigger to Lambdas 1 and 2

What actually happened?

  1. Created EventBridge and Rule with Event pattern
  2. Lambda 0 to trigger rule with event pattern
  3. EventBridge created Targets for Lambdas 1 and 2
  4. EventBridge attached trigger to Lambda 1
  5. 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

fn_1_trigger fn_2_trigger EventBridge_rule_targets


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
juweekscommented, Dec 10, 2020

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 !

1reaction
shivlakscommented, Dec 10, 2020

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 a p1 so we can prioritize getting a fix out.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found