-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sqs): distribute terraform queue module
- Loading branch information
1 parent
d32a3c0
commit bba0698
Showing
5 changed files
with
225 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
locals { | ||
name = "${var.service}-${var.environment}-${var.title}" | ||
} | ||
|
||
resource "aws_sqs_queue" "dead_letter_queue" { # define the deadletter queue | ||
name = "${local.name}-dlq" # https://en.wikipedia.org/wiki/Dead_letter_queue | ||
message_retention_seconds = 14 * 24 * 60 * 60 # keep a message up to 14 days in the deadletter queue, the max amount of time permitted | ||
tags = var.tags | ||
} | ||
resource "aws_sqs_queue" "queue" { # define the queeu | ||
name = "${local.name}-llq" # live letter queue | ||
visibility_timeout_seconds = var.visibility_timeout_seconds | ||
message_retention_seconds = var.message_retention_seconds # keep a message up to 3 days in the queue | ||
delay_seconds = var.delay_seconds # wait 15 seconds before reading messages | ||
redrive_policy = jsonencode({ | ||
maxReceiveCount = var.max_receive_count | ||
deadLetterTargetArn = aws_sqs_queue.dead_letter_queue.arn # and if feailed each time, send here | ||
}) | ||
tags = var.tags | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
output "arn" { | ||
value = aws_sqs_queue.queue.arn | ||
description = "the arn of the queue" | ||
} | ||
output "id" { | ||
value = aws_sqs_queue.queue.id | ||
description = "the id of the queue" | ||
} | ||
output "dlq_arn" { | ||
value = aws_sqs_queue.dead_letter_queue.arn | ||
description = "the arn of the dead letter queue" | ||
} | ||
output "dlq_id" { | ||
value = aws_sqs_queue.dead_letter_queue.id | ||
description = "the id of the dead letter queue" | ||
} | ||
output "dlq_name" { | ||
value = aws_sqs_queue.dead_letter_queue.name | ||
description = "the name of the dead letter queue" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
variable "service" { | ||
type = string | ||
description = "the name of the service for whom this queue is being provisioned. for example: 'svc-notifications'" | ||
} | ||
variable "environment" { | ||
type = string | ||
description = "the name of the environment in which this queue is being provisioned. for example: 'dev', 'prod', 'test', etc" | ||
} | ||
variable "title" { | ||
type = string | ||
description = "a distinct name that explains what type of messages you will find in this queue. for example: 'async-task-remind-user-to-brush-teeth'" | ||
} | ||
variable "tags" { | ||
type = map(any) | ||
description = "tags to help you categorize your resources" | ||
} | ||
variable "visibility_timeout_seconds" { | ||
type = number | ||
default = 30 # the aws default | ||
description = "how long to keep a message invisible after it is read. i.e., the period of time between retries in processing the same message" | ||
} | ||
variable "message_retention_seconds" { | ||
type = number | ||
default = 1209600 # the aws default | ||
description = "how long messages stay in the queue before expiring without being removed" | ||
} | ||
variable "delay_seconds" { | ||
type = number | ||
default = 0 # the aws default | ||
description = "the number of seconds between the time the message is added to the queue and the time the message is available for being read from the queue" | ||
} | ||
variable "max_receive_count" { | ||
type = number | ||
default = 3 # a lucky number | ||
description = "the number of times to try to process the message before moving it into the dead letter queue" | ||
} | ||
|
||
|