diff --git a/event-notifications.tf b/event-notifications.tf index f13a88a..4e50fd0 100644 --- a/event-notifications.tf +++ b/event-notifications.tf @@ -10,7 +10,7 @@ data "aws_iam_policy_document" "queue" { } actions = ["sqs:SendMessage"] - resources = ["arn:aws:sqs:*:*:${replace("${var.name}-${var.event_notification_config.name_suffix}", "/\\W+/", "_")}"] + resources = ["arn:aws:sqs:*:*:${local.queue_name}"] condition { test = "ArnEquals" @@ -23,7 +23,7 @@ data "aws_iam_policy_document" "queue" { resource "aws_sqs_queue" "queue" { count = var.event_notification_config.target_type == "sqs" ? 1 : 0 - name = replace("${var.name}-${var.event_notification_config.name_suffix}", "/\\W+/", "_") + name = local.queue_name policy = data.aws_iam_policy_document.queue[0].json } diff --git a/locals.tf b/locals.tf index 44de13b..c3be82e 100644 --- a/locals.tf +++ b/locals.tf @@ -1,4 +1,5 @@ locals { name_formed = replace(var.name, "/\\W|_|\\s/", "-") iam_user_name = coalesce(var.iam_user_name, "${local.name_formed}-s3-usr") + queue_name = replace("${var.name}-${var.event_notification_config.name_suffix}", "/\\W+/", "_") }