EventBridge Targets
Last updated
Last updated
Each rule can have multiple targets and these are displayed in the AWS console when setting or editing a rule. Different rules can all point to the same target if you wish.
Targets are where the event data is forwarded to when a rule is triggered. If the rule is triggered by a schedule (i.e., without events) it can be used to invoke a target such as an AWS Lambda function.
Targets can be another event bus, an EventBridge API destination (for third-party applications), or another AWS service. To target AWS services (such as Lambda or SNS) in other regions or accounts, you must do so via an event bus in that account or region, so events should be forwarded there first. To add a target, simply choose the target type, and select the target from the options.
This is where the Event Buses are, highlighted is the customer bus.
This is where the rules are stored. An existing rule is already in place for the previously mentioned bus.
Creating a new rule called Instance-Tracker, This will be on the default Event Bus. I will be skipping the ‘sample events’ section and ensuring my rule captures any EC2 event of the specific type – ‘Instance state-change notification’ . The rule should also target the instance-notifier SNS Topic
Rule successfully created
Now creating a schedule called ‘backup’ in the default schedule group.
The task should run on a recurring schedule every five minutes. With any flexible time window. It should Target the AWS Lambda Invoke API and Invoke the existing image-instance lambda function. It should use the existing role Amazon_EventBridge_Scheduler_image_instance_lambda as the execution role.
Noe switching to US-east-1 region. I am going to create a rule called ‘object-scans’ to capture events from S3 of type ‘object-level API call via CloudTrail’ for the PutObject operation on any bucket. The rule should target the ‘metrolio_central_monitoring custom bus in the eu-west-1 region, using the existing eventBridge-events role