-
-
Save mohsiur/e743859fc0710b582c809ee6f6dd363f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Manage standard queues and their access policies | |
resource "aws_sqs_queue" "sqs_standard_queues" { | |
for_each = { | |
for queue in local.sqs_standard_queues : queue.name => queue | |
if queue.dlq == null | |
} | |
name = each.value.name | |
visibility_timeout_seconds = each.value.visibility_timeout_seconds | |
} | |
resource "aws_sqs_queue_policy" "sqs_standard_queue_policies" { | |
for_each = { | |
for queue in local.sqs_standard_queues : queue.name => queue | |
if queue.dlq == null | |
} | |
queue_url = aws_sqs_queue.sqs_standard_queues[each.value.name].id | |
policy = file("${path.root}/conf/sqs-policy.json") | |
} | |
## Manage standard queues with DLQ enabled and their access poicies | |
resource "aws_sqs_queue" "sqs_dlq_enabled_standard_queues" { | |
for_each = { | |
for queue in local.sqs_standard_queues : queue.name => queue | |
if queue.dlq != null | |
} | |
name = each.value.name | |
visibility_timeout_seconds = each.value.visibility_timeout_seconds | |
redrive_policy = jsonencode({ | |
deadLetterTargetArn = aws_sqs_queue.sqs_standard_queues["${terraform.workspace}-${each.value.dlq.name}"].arn | |
maxReceiveCount = each.value.dlq.max_recieve_count | |
}) | |
} | |
resource "aws_sqs_queue_policy" "sqs_dlq_enabled_standard_queue_policies" { | |
for_each = { | |
for queue in local.sqs_standard_queues : queue.name => queue | |
if queue.dlq != null | |
} | |
queue_url = aws_sqs_queue.sqs_dlq_enabled_standard_queues[each.value.name].id | |
policy = file("${path.root}/conf/sqs-dlq-policy.json") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment