From 58426c5cfe2534ed0c5b6e2be0ff3f875ff7cc68 Mon Sep 17 00:00:00 2001 From: Jay Whitwell Date: Wed, 18 Dec 2024 11:15:19 +0000 Subject: [PATCH] add event target bus name --- .../environment/region/modules/event_bus/bus.tf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/terraform/environment/region/modules/event_bus/bus.tf b/terraform/environment/region/modules/event_bus/bus.tf index 512d5ac59e..3ccac565f0 100644 --- a/terraform/environment/region/modules/event_bus/bus.tf +++ b/terraform/environment/region/modules/event_bus/bus.tf @@ -27,7 +27,7 @@ resource "aws_cloudwatch_event_rule" "receive_events_from_mlpa" { } resource "aws_cloudwatch_event_bus_policy" "cross_account_receive" { - count = length(var.receive_account_ids) > 0 ? 1 : 0 + count = length(var.receive_account_ids) > 0 && var.event_bus_enabled ? 1 : 0 event_bus_name = aws_cloudwatch_event_bus.main[0].name policy = data.aws_iam_policy_document.cross_account_receive[0].json provider = aws.region @@ -54,7 +54,13 @@ data "aws_iam_policy_document" "cross_account_receive" { } resource "aws_cloudwatch_event_target" "receive_events" { - count = var.event_bus_enabled ? 1 : 0 - rule = aws_cloudwatch_event_rule.receive_events_from_mlpa[0].name - arn = aws_sqs_queue.receive_events_queue[0].arn + count = var.event_bus_enabled ? 1 : 0 + rule = aws_cloudwatch_event_rule.receive_events_from_mlpa[0].name + arn = aws_sqs_queue.receive_events_queue[0].arn + event_bus_name = aws_cloudwatch_event_bus.main[0].name + dead_letter_config { + arn = aws_sqs_queue.receive_events_deadletter[0].arn + } + + provider = aws.region }