Skip to content

Commit

Permalink
feat: allow customizing the dlq name, add outputs (#61)
Browse files Browse the repository at this point in the history
## Description
Allow specifying the name of the created dlq compared to using normal
queue name + "-dlq". Add outputs of the created sqs queues.

## Motivation and Context
We want to have a custom named sqs queue from which we can read using a
different consumer, as such the default -dlq ending would be misleading.
  • Loading branch information
bt-justtrack authored Oct 2, 2024
1 parent 25bba0e commit 8a62556
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Terraform module which creates a sqs queue
| <a name="input_dlq_alarm_enabled"></a> [dlq\_alarm\_enabled](#input\_dlq\_alarm\_enabled) | Defines if the DLQ alarm should be created. | `bool` | `true` | no |
| <a name="input_dlq_enabled"></a> [dlq\_enabled](#input\_dlq\_enabled) | Defines if Dead Letter Queue (DLQ) is enabled. | `bool` | `true` | no |
| <a name="input_dlq_max_receive_count"></a> [dlq\_max\_receive\_count](#input\_dlq\_max\_receive\_count) | The maximum number of times a message can be received from the DLQ before it's discarded. | `number` | `5` | no |
| <a name="input_dlq_name"></a> [dlq\_name](#input\_dlq\_name) | Sets a custom name for the to be created dlq. | `string` | `null` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
| <a name="input_fifo_queue"></a> [fifo\_queue](#input\_fifo\_queue) | Boolean designating a FIFO queue | `bool` | `false` | no |
Expand All @@ -71,5 +72,12 @@ Terraform module which creates a sqs queue

## Outputs

No outputs.
| Name | Description |
|------|-------------|
| <a name="output_dlq_queue_arn"></a> [dlq\_queue\_arn](#output\_dlq\_queue\_arn) | queue arn of the dead letter sqs queue |
| <a name="output_dlq_queue_name"></a> [dlq\_queue\_name](#output\_dlq\_queue\_name) | queue name of the dead letter sqs queue |
| <a name="output_dlq_queue_url"></a> [dlq\_queue\_url](#output\_dlq\_queue\_url) | queue url of the dead letter sqs queue |
| <a name="output_sqs_queue_arn"></a> [sqs\_queue\_arn](#output\_sqs\_queue\_arn) | queue arn of the main sqs queue |
| <a name="output_sqs_queue_name"></a> [sqs\_queue\_name](#output\_sqs\_queue\_name) | queue name of the main sqs queue |
| <a name="output_sqs_queue_url"></a> [sqs\_queue\_url](#output\_sqs\_queue\_url) | queue url of the main sqs queue |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module "sqs" {
create_dlq = var.dlq_enabled
create_queue_policy = length(var.subscription) >= 1
delay_seconds = var.delay_seconds
dlq_name = var.dlq_name
fifo_queue = var.fifo_queue
message_retention_seconds = var.message_retention_seconds
name = module.this.id
Expand Down
28 changes: 28 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
output "sqs_queue_url" {
value = module.sqs.queue_url
description = "queue url of the main sqs queue"
}
output "sqs_queue_arn" {
value = module.sqs.queue_arn
description = "queue arn of the main sqs queue"
}

output "sqs_queue_name" {
value = module.sqs.queue_name
description = "queue name of the main sqs queue"
}

output "dlq_queue_url" {
value = module.sqs.dead_letter_queue_url
description = "queue url of the dead letter sqs queue"
}

output "dlq_queue_arn" {
value = module.sqs.dead_letter_queue_arn
description = "queue arn of the dead letter sqs queue"
}

output "dlq_queue_name" {
value = module.sqs.dead_letter_queue_name
description = "queue name of the dead letter sqs queue"
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ variable "dlq_max_receive_count" {
default = 5
}

variable "dlq_name" {
type = string
description = "Sets a custom name for the to be created dlq."
default = null
}

variable "fifo_queue" {
type = bool
description = "Boolean designating a FIFO queue"
Expand Down

0 comments on commit 8a62556

Please sign in to comment.