Skip to content

Commit

Permalink
Add cross-account event rule to specific bus (#730)
Browse files Browse the repository at this point in the history
Ensure events are properly sent cross-account between our event buses. Without this, the rule is added to the "default" bus, which is not where messages are sent.

Fixes VEGA-2074
  • Loading branch information
gregtyler authored Sep 26, 2023
1 parent d57694b commit 0f197f2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions terraform/environment/region/modules/event_bus/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ data "aws_iam_policy_document" "cross_account_put_access" {
}

resource "aws_cloudwatch_event_rule" "cross_account_put" {
name = "${data.aws_default_tags.current.tags.environment-name}-cross-account-put"
description = "forward events to bus in remote account"
name = "${data.aws_default_tags.current.tags.environment-name}-cross-account-put"
description = "forward events to bus in remote account"
event_bus_name = aws_cloudwatch_event_bus.main.name

event_pattern = jsonencode({
source = ["opg.poas.makeregister"]
Expand All @@ -45,9 +46,10 @@ resource "aws_cloudwatch_event_rule" "cross_account_put" {
}

resource "aws_cloudwatch_event_target" "cross_account_put" {
target_id = "${data.aws_default_tags.current.tags.environment-name}-cross-account-put-event"
arn = var.target_event_bus_arn
rule = aws_cloudwatch_event_rule.cross_account_put.name
role_arn = var.iam_role.arn
provider = aws.region
target_id = "${data.aws_default_tags.current.tags.environment-name}-cross-account-put-event"
event_bus_name = aws_cloudwatch_event_bus.main.name
arn = var.target_event_bus_arn
rule = aws_cloudwatch_event_rule.cross_account_put.name
role_arn = var.iam_role.arn
provider = aws.region
}

0 comments on commit 0f197f2

Please sign in to comment.