79243261

Date: 2024-12-02 07:33:50
Score: 1
Natty:
Report link

I came upon this thread, https://github.com/aws/aws-cdk/issues/6184 Based on that I was able to get it to work like this:

export class EventBridgeRuleStack extends cdk.Stack {
    constructor(
        scope: Construct,
        id: string,
        eventBus: cdk.aws_events.IEventBus,
        lambda: cdk.aws_lambda.IFunction,
        props?: cdk.StackProps) {
        super(scope, id, props);
        
        // Create an EventBridge rule
        const rule = new cdk.aws_events.Rule(this, "EventRule", {
            eventBus: eventBus,
            ruleName: "stripe-event",
            eventPattern: {
                source: cdk.aws_events.Match.prefix("aws.partner/stripe.com")
            }
        });

        rule.addEventPattern({source: []})

        // Add the Lambda function as a target
        rule.addTarget(new cdk.aws_events_targets.LambdaFunction(lambda));

    }
}
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: techhighlands