Cross-Account Event Routing AWS
When building cloud-based event-driven systems, you may want to trigger with those events or publish to any consumers. AWS EventBridge comes handy to validate events, configure rules, patterns and targets to create consumer of events.
Amazon Event-bridge provide a easy solution that allows us to listen to those events raised via different, AWS Services, AWS partner tools, and custom events. Once a event is published to the event bus. Event Bus will further pass to matched rule i.e AWS Event-bridge Rules, Event-bridge will downstream those events to consumer or targets.
T A R G E T S
Targets is endpoint a rule can invoke.
Those destination service where events data is sent after successfully passing event rule validation.
Whenever a event trigger a rule, all of the targets assocaited with that rule are invoked simultaneously.
Eventbridge bus will need permission to trigger any consumer targets.
Cross-Account Event Routing Demo
let’s create a eventbus rule on source account (Account 1) and set it’s target to cross-account custom event-bus from Terraform.
resource "aws_cloudwatch_event_rule" "this" {
name = "finops-event-rule"
event_bus_name = "default"
description = "Capture All EC2 Events V2"
event_pattern = jsonencode({
source = ["aws.ec2"]
})
}
resource "aws_cloudwatch_event_target" "event_target_this" {
rule = aws_cloudwatch_event_rule.this.name
arn = var.event_bus_arn
role_arn = var.iam_role_arn
}
Subscribe to my newsletter
Read articles from Roshan Poudel directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Roshan Poudel
Roshan Poudel
DevOps / Cloud Engineer