How do EventBridge rules and targets work together to trigger actions?
Short answer
A rule defines the event pattern or schedule that determines when it should fire, while a target defines what action should happen when the rule matches, such as invoking a Lambda function, sending a message to an SQS queue, or starting a Step Functions workflow, and a single…
Advertisement
AModel answer
A rule defines the event pattern or schedule that determines when it should fire, while a target defines what action should happen when the rule matches, such as invoking a Lambda function, sending a message to an SQS queue, or starting a Step Functions workflow, and a single rule can have multiple targets, meaning one matching event can trigger several different actions simultaneously.
Example
aws events put-targets --rule 'OrderPlacedRule' --targets 'Id'='1','Arn'='arn:aws:lambda:us-east-1:123456789012:function:sendConfirmationEmail'
Real-world example
An order processing system configures a single EventBridge rule with three separate targets, so a single order placed event simultaneously triggers an inventory update, a shipping label creation, and a customer confirmation email.
Likely follow-ups
- What is the maximum number of targets a single rule can have?
- What happens if one target fails while others succeed?
Related topics