Skip to content

Commit

Permalink
feat: Add option to disable creation of redrive policy for the dead l…
Browse files Browse the repository at this point in the history
…etter queue (#60)

Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
  • Loading branch information
jebbens and bryantbiggs authored Oct 21, 2023
1 parent e195083 commit c4db9a6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ No modules.
| <a name="input_create"></a> [create](#input\_create) | Whether to create SQS queue | `bool` | `true` | no |
| <a name="input_create_dlq"></a> [create\_dlq](#input\_create\_dlq) | Determines whether to create SQS dead letter queue | `bool` | `false` | no |
| <a name="input_create_dlq_queue_policy"></a> [create\_dlq\_queue\_policy](#input\_create\_dlq\_queue\_policy) | Whether to create SQS queue policy | `bool` | `false` | no |
| <a name="input_create_dlq_redrive_allow_policy"></a> [create\_dlq\_redrive\_allow\_policy](#input\_create\_dlq\_redrive\_allow\_policy) | Determines whether to create a redrive allow policy for the dead letter queue. | `bool` | `true` | no |
| <a name="input_create_queue_policy"></a> [create\_queue\_policy](#input\_create\_queue\_policy) | Whether to create SQS queue policy | `bool` | `false` | no |
| <a name="input_deduplication_scope"></a> [deduplication\_scope](#input\_deduplication\_scope) | Specifies whether message deduplication occurs at the message group or queue level | `string` | `null` | no |
| <a name="input_delay_seconds"></a> [delay\_seconds](#input\_delay\_seconds) | The time in seconds that the delivery of all messages in the queue will be delayed. An integer from 0 to 900 (15 minutes) | `number` | `null` | no |
Expand Down
1 change: 1 addition & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ module "sqs_with_dlq" {
# default is 5 for this module
maxReceiveCount = 10
}
create_dlq_redrive_allow_policy = false

# Dead letter queue policy
# Not required - just showing example
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ resource "aws_sqs_queue_redrive_allow_policy" "this" {
}

resource "aws_sqs_queue_redrive_allow_policy" "dlq" {
count = var.create && var.create_dlq ? 1 : 0
count = var.create && var.create_dlq && var.create_dlq_redrive_allow_policy ? 1 : 0

queue_url = aws_sqs_queue.dlq[0].url
redrive_allow_policy = jsonencode(merge(
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ variable "dlq_receive_wait_time_seconds" {
default = null
}

variable "create_dlq_redrive_allow_policy" {
description = "Determines whether to create a redrive allow policy for the dead letter queue."
type = bool
default = true
}

variable "dlq_redrive_allow_policy" {
description = "The JSON policy to set up the Dead Letter Queue redrive permission, see AWS docs."
type = any
Expand Down
1 change: 1 addition & 0 deletions wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module "wrapper" {
dlq_message_retention_seconds = try(each.value.dlq_message_retention_seconds, var.defaults.dlq_message_retention_seconds, null)
dlq_name = try(each.value.dlq_name, var.defaults.dlq_name, null)
dlq_receive_wait_time_seconds = try(each.value.dlq_receive_wait_time_seconds, var.defaults.dlq_receive_wait_time_seconds, null)
create_dlq_redrive_allow_policy = try(each.value.create_dlq_redrive_allow_policy, var.defaults.create_dlq_redrive_allow_policy, true)
dlq_redrive_allow_policy = try(each.value.dlq_redrive_allow_policy, var.defaults.dlq_redrive_allow_policy, {})
dlq_sqs_managed_sse_enabled = try(each.value.dlq_sqs_managed_sse_enabled, var.defaults.dlq_sqs_managed_sse_enabled, true)
dlq_visibility_timeout_seconds = try(each.value.dlq_visibility_timeout_seconds, var.defaults.dlq_visibility_timeout_seconds, null)
Expand Down

0 comments on commit c4db9a6

Please sign in to comment.