Skip to content

Commit e2bacae

Browse files
committed
add support for customizing dlq fifo throughput limit
Signed-off-by: Aditya Menon <[email protected]>
1 parent debb3cb commit e2bacae

File tree

7 files changed

+121
-1
lines changed

7 files changed

+121
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ No modules.
211211
| <a name="input_dlq_content_based_deduplication"></a> [dlq\_content\_based\_deduplication](#input\_dlq\_content\_based\_deduplication) | Enables content-based deduplication for FIFO queues | `bool` | `null` | no |
212212
| <a name="input_dlq_deduplication_scope"></a> [dlq\_deduplication\_scope](#input\_dlq\_deduplication\_scope) | Specifies whether message deduplication occurs at the message group or queue level | `string` | `null` | no |
213213
| <a name="input_dlq_delay_seconds"></a> [dlq\_delay\_seconds](#input\_dlq\_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 |
214+
| <a name="input_dlq_fifo_throughput_limit"></a> [dlq\_fifo\_throughput\_limit](#input\_dlq\_fifo\_throughput\_limit) | Specifies whether the Dead Letter Queue FIFO queue throughput quota applies to the entire queue or per message group | `string` | `null` | no |
214215
| <a name="input_dlq_kms_data_key_reuse_period_seconds"></a> [dlq\_kms\_data\_key\_reuse\_period\_seconds](#input\_dlq\_kms\_data\_key\_reuse\_period\_seconds) | The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours) | `number` | `null` | no |
215216
| <a name="input_dlq_kms_master_key_id"></a> [dlq\_kms\_master\_key\_id](#input\_dlq\_kms\_master\_key\_id) | The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK | `string` | `null` | no |
216217
| <a name="input_dlq_message_retention_seconds"></a> [dlq\_message\_retention\_seconds](#input\_dlq\_message\_retention\_seconds) | The number of seconds Amazon SQS retains a message. Integer representing seconds, from 60 (1 minute) to 1209600 (14 days) | `number` | `null` | no |

examples/complete/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Note that this example may create resources which cost money. Run `terraform des
4545
| <a name="module_disabled_sqs"></a> [disabled\_sqs](#module\_disabled\_sqs) | ../../ | n/a |
4646
| <a name="module_fifo_sqs"></a> [fifo\_sqs](#module\_fifo\_sqs) | ../../ | n/a |
4747
| <a name="module_sqs_with_dlq"></a> [sqs\_with\_dlq](#module\_sqs\_with\_dlq) | ../../ | n/a |
48+
| <a name="module_sqs_with_fifo_dlq"></a> [sqs\_with\_fifo\_dlq](#module\_sqs\_with\_fifo\_dlq) | ../../ | n/a |
4849
| <a name="module_sse_encrypted_dlq_sqs"></a> [sse\_encrypted\_dlq\_sqs](#module\_sse\_encrypted\_dlq\_sqs) | ../../ | n/a |
4950
| <a name="module_sse_encrypted_sqs"></a> [sse\_encrypted\_sqs](#module\_sse\_encrypted\_sqs) | ../../ | n/a |
5051
| <a name="module_unencrypted_sqs"></a> [unencrypted\_sqs](#module\_unencrypted\_sqs) | ../../ | n/a |
@@ -104,6 +105,14 @@ No inputs.
104105
| <a name="output_sqs_with_dlq_queue_id"></a> [sqs\_with\_dlq\_queue\_id](#output\_sqs\_with\_dlq\_queue\_id) | The URL for the created Amazon SQS queue |
105106
| <a name="output_sqs_with_dlq_queue_name"></a> [sqs\_with\_dlq\_queue\_name](#output\_sqs\_with\_dlq\_queue\_name) | The name of the SQS queue |
106107
| <a name="output_sqs_with_dlq_queue_url"></a> [sqs\_with\_dlq\_queue\_url](#output\_sqs\_with\_dlq\_queue\_url) | Same as `queue_id`: The URL for the created Amazon SQS queue |
108+
| <a name="output_sqs_with_fifo_dlq_dlq_arn"></a> [sqs\_with\_fifo\_dlq\_dlq\_arn](#output\_sqs\_with\_fifo\_dlq\_dlq\_arn) | The ARN of the SQS queue |
109+
| <a name="output_sqs_with_fifo_dlq_dlq_id"></a> [sqs\_with\_fifo\_dlq\_dlq\_id](#output\_sqs\_with\_fifo\_dlq\_dlq\_id) | The URL for the created Amazon SQS queue |
110+
| <a name="output_sqs_with_fifo_dlq_dlq_name"></a> [sqs\_with\_fifo\_dlq\_dlq\_name](#output\_sqs\_with\_fifo\_dlq\_dlq\_name) | The name of the SQS queue |
111+
| <a name="output_sqs_with_fifo_dlq_dlq_url"></a> [sqs\_with\_fifo\_dlq\_dlq\_url](#output\_sqs\_with\_fifo\_dlq\_dlq\_url) | Same as `dead_letter_queue_id`: The URL for the created Amazon SQS queue |
112+
| <a name="output_sqs_with_fifo_dlq_queue_arn"></a> [sqs\_with\_fifo\_dlq\_queue\_arn](#output\_sqs\_with\_fifo\_dlq\_queue\_arn) | The ARN of the SQS queue |
113+
| <a name="output_sqs_with_fifo_dlq_queue_id"></a> [sqs\_with\_fifo\_dlq\_queue\_id](#output\_sqs\_with\_fifo\_dlq\_queue\_id) | The URL for the created Amazon SQS queue |
114+
| <a name="output_sqs_with_fifo_dlq_queue_name"></a> [sqs\_with\_fifo\_dlq\_queue\_name](#output\_sqs\_with\_fifo\_dlq\_queue\_name) | The name of the SQS queue |
115+
| <a name="output_sqs_with_fifo_dlq_queue_url"></a> [sqs\_with\_fifo\_dlq\_queue\_url](#output\_sqs\_with\_fifo\_dlq\_queue\_url) | Same as `queue_id`: The URL for the created Amazon SQS queue |
107116
| <a name="output_sse_encrypted_dlq_sqs_dlq_arn"></a> [sse\_encrypted\_dlq\_sqs\_dlq\_arn](#output\_sse\_encrypted\_dlq\_sqs\_dlq\_arn) | The ARN of the SQS queue |
108117
| <a name="output_sse_encrypted_dlq_sqs_dlq_id"></a> [sse\_encrypted\_dlq\_sqs\_dlq\_id](#output\_sse\_encrypted\_dlq\_sqs\_dlq\_id) | The URL for the created Amazon SQS queue |
109118
| <a name="output_sse_encrypted_dlq_sqs_dlq_name"></a> [sse\_encrypted\_dlq\_sqs\_dlq\_name](#output\_sse\_encrypted\_dlq\_sqs\_dlq\_name) | The name of the SQS queue |

examples/complete/main.tf

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,68 @@ module "sqs_with_dlq" {
161161
tags = local.tags
162162
}
163163

164+
module "sqs_with_fifo_dlq" {
165+
source = "../../"
166+
167+
# This creates both the queue and the dead letter queue together
168+
169+
name = "${local.name}-sqs-with-fifo-dlq"
170+
fifo_queue = true
171+
172+
deduplication_scope = "messageGroup"
173+
fifo_throughput_limit = "perMessageGroupId"
174+
175+
# Policy
176+
# Not required - just showing example
177+
create_queue_policy = true
178+
queue_policy_statements = {
179+
account = {
180+
sid = "AccountReadWrite"
181+
actions = [
182+
"sqs:SendMessage",
183+
"sqs:ReceiveMessage",
184+
]
185+
principals = [
186+
{
187+
type = "AWS"
188+
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
189+
}
190+
]
191+
}
192+
}
193+
194+
# Dead letter queue
195+
create_dlq = true
196+
redrive_policy = {
197+
# default is 5 for this module
198+
maxReceiveCount = 10
199+
}
200+
create_dlq_redrive_allow_policy = false
201+
202+
# Dead letter queue policy
203+
# Not required - just showing example
204+
create_dlq_queue_policy = true
205+
dlq_queue_policy_statements = {
206+
account = {
207+
sid = "AccountReadWrite"
208+
actions = [
209+
"sqs:SendMessage",
210+
"sqs:ReceiveMessage",
211+
]
212+
principals = [
213+
{
214+
type = "AWS"
215+
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
216+
}
217+
]
218+
}
219+
}
220+
dlq_deduplication_scope = "queue"
221+
dlq_fifo_throughput_limit = "perQueue"
222+
223+
tags = local.tags
224+
}
225+
164226
module "disabled_sqs" {
165227
source = "../../"
166228

examples/complete/outputs.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,47 @@ output "sqs_with_dlq_dlq_name" {
285285
value = module.sqs_with_dlq.dead_letter_queue_name
286286
}
287287

288+
# With FIFO Dead Letter Queue
289+
output "sqs_with_fifo_dlq_queue_id" {
290+
description = "The URL for the created Amazon SQS queue"
291+
value = module.sqs_with_fifo_dlq.queue_id
292+
}
293+
294+
output "sqs_with_fifo_dlq_queue_arn" {
295+
description = "The ARN of the SQS queue"
296+
value = module.sqs_with_fifo_dlq.queue_arn
297+
}
298+
299+
output "sqs_with_fifo_dlq_queue_url" {
300+
description = "Same as `queue_id`: The URL for the created Amazon SQS queue"
301+
value = module.sqs_with_fifo_dlq.queue_url
302+
}
303+
304+
output "sqs_with_fifo_dlq_queue_name" {
305+
description = "The name of the SQS queue"
306+
value = module.sqs_with_fifo_dlq.queue_name
307+
}
308+
309+
output "sqs_with_fifo_dlq_dlq_id" {
310+
description = "The URL for the created Amazon SQS queue"
311+
value = module.sqs_with_fifo_dlq.dead_letter_queue_id
312+
}
313+
314+
output "sqs_with_fifo_dlq_dlq_arn" {
315+
description = "The ARN of the SQS queue"
316+
value = module.sqs_with_fifo_dlq.dead_letter_queue_arn
317+
}
318+
319+
output "sqs_with_fifo_dlq_dlq_url" {
320+
description = "Same as `dead_letter_queue_id`: The URL for the created Amazon SQS queue"
321+
value = module.sqs_with_fifo_dlq.dead_letter_queue_url
322+
}
323+
324+
output "sqs_with_fifo_dlq_dlq_name" {
325+
description = "The name of the SQS queue"
326+
value = module.sqs_with_fifo_dlq.dead_letter_queue_name
327+
}
328+
288329
# Disabled
289330
output "disabled_sqs_queue_id" {
290331
description = "The URL for the created Amazon SQS queue"

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ resource "aws_sqs_queue" "dlq" {
137137
delay_seconds = try(coalesce(var.dlq_delay_seconds, var.delay_seconds), null)
138138
# If source queue is FIFO, DLQ must also be FIFO and vice versa
139139
fifo_queue = var.fifo_queue
140-
fifo_throughput_limit = var.fifo_throughput_limit
140+
fifo_throughput_limit = try(coalesce(var.dlq_fifo_throughput_limit, var.fifo_throughput_limit), null)
141141
kms_data_key_reuse_period_seconds = try(coalesce(var.dlq_kms_data_key_reuse_period_seconds, var.kms_data_key_reuse_period_seconds), null)
142142
kms_master_key_id = local.dlq_kms_master_key_id
143143
max_message_size = var.max_message_size

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ variable "dlq_sqs_managed_sse_enabled" {
214214
default = true
215215
}
216216

217+
variable "dlq_fifo_throughput_limit" {
218+
description = "Specifies whether the Dead Letter Queue FIFO queue throughput quota applies to the entire queue or per message group"
219+
type = string
220+
default = null
221+
}
222+
217223
variable "dlq_visibility_timeout_seconds" {
218224
description = "The visibility timeout for the queue. An integer from 0 to 43200 (12 hours)"
219225
type = number

wrappers/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module "wrapper" {
1414
dlq_content_based_deduplication = try(each.value.dlq_content_based_deduplication, var.defaults.dlq_content_based_deduplication, null)
1515
dlq_deduplication_scope = try(each.value.dlq_deduplication_scope, var.defaults.dlq_deduplication_scope, null)
1616
dlq_delay_seconds = try(each.value.dlq_delay_seconds, var.defaults.dlq_delay_seconds, null)
17+
dlq_fifo_throughput_limit = try(each.value.dlq_fifo_throughput_limit, var.defaults.dlq_fifo_throughput_limit, null)
1718
dlq_kms_data_key_reuse_period_seconds = try(each.value.dlq_kms_data_key_reuse_period_seconds, var.defaults.dlq_kms_data_key_reuse_period_seconds, null)
1819
dlq_kms_master_key_id = try(each.value.dlq_kms_master_key_id, var.defaults.dlq_kms_master_key_id, null)
1920
dlq_message_retention_seconds = try(each.value.dlq_message_retention_seconds, var.defaults.dlq_message_retention_seconds, null)

0 commit comments

Comments
 (0)