Skip to content

Commit

Permalink
expose access to policy and receive wait time
Browse files Browse the repository at this point in the history
  • Loading branch information
snemetz committed Aug 23, 2019
1 parent dff233e commit 8ebeab8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ module "labels" {
team = "${var.team}"
}

# TODO: add KMS support $$
# kms_master_key_id = "alias/aws/xxx"
# kms_data_key_reuse_period_seconds = 300 (60 - 86400)

resource "aws_sqs_queue" "queue_deadletter" {
count = "${module.enable.value && module.enable_dlq.value && (var.dlq_arn == "" || module.dlq_only.value) ? length(module.labels.id) : 0}"
name = "${module.labels.id[count.index]}-dlq"
delay_seconds = "${var.dlq_delay_seconds != "" ? var.dlq_delay_seconds : var.delay_seconds}"
max_message_size = "${var.dlq_max_message_size != "" ? var.dlq_max_message_size : var.max_message_size}"
message_retention_seconds = "${var.dlq_message_retention_seconds != "" ? var.dlq_message_retention_seconds : var.message_retention_seconds}"
policy = "${var.dlq_policy != "" ? var.dlq_policy : var.policy}"
receive_wait_time_seconds = "${var.dlq_receive_wait_time_seconds != "" ? var.dlq_receive_wait_time_seconds : var.receive_wait_time_seconds}"
visibility_timeout_seconds = "${var.dlq_visibility_timeout_seconds != "" ? var.dlq_visibility_timeout_seconds : var.visibility_timeout_seconds}"

tags = "${merge(
Expand All @@ -59,6 +65,8 @@ resource "aws_sqs_queue" "queue" {
delay_seconds = "${var.delay_seconds}"
max_message_size = "${var.max_message_size}"
message_retention_seconds = "${var.message_retention_seconds}"
policy = "${var.policy}"
receive_wait_time_seconds = "${var.receive_wait_time_seconds}"
visibility_timeout_seconds = "${var.visibility_timeout_seconds}"
tags = "${module.labels.tags[count.index]}"
}
Expand All @@ -69,6 +77,8 @@ resource "aws_sqs_queue" "queue_with_dlq" {
delay_seconds = "${var.delay_seconds}"
max_message_size = "${var.max_message_size}"
message_retention_seconds = "${var.message_retention_seconds}"
policy = "${var.policy}"
receive_wait_time_seconds = "${var.receive_wait_time_seconds}"
visibility_timeout_seconds = "${var.visibility_timeout_seconds}"
tags = "${module.labels.tags[count.index]}"
redrive_policy = "{\"deadLetterTargetArn\":\"${var.dlq_arn != "" ? var.dlq_arn : element(concat(aws_sqs_queue.queue_deadletter.*.arn, list("")), count.index)}\",\"maxReceiveCount\":${var.max_receive_count}}"
Expand Down
17 changes: 16 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ variable "dlq_arn" {
description = "Override DLQ with an existing DLQ"
default = ""
}

variable "dlq_delay_seconds" {
description = "Dead letter queue: The time in seconds that the delivery of all messages in the queue will be delayed"
default = ""
Expand All @@ -123,6 +122,14 @@ variable "dlq_only" {
description = "Only create DLQ"
default = false
}
variable "dlq_policy" {
description = "DLQ IAM Policy"
default = ""
}
variable "dlq_receive_wait_time_seconds" {
description = "The time for which a ReceiveMessage call will wait for a message to arrive (long polling) before returning"
default = "20"
}

variable "dlq_visibility_timeout_seconds" {
description = "Dead letter queue: The visibility timeout for the queue"
Expand All @@ -143,6 +150,14 @@ variable "message_retention_seconds" {
description = "The number of seconds Amazon SQS retains a message"
default = "1209600"
}
variable "policy" {
description = "Queue IAM Policy"
default = ""
}
variable "receive_wait_time_seconds" {
description = "The time for which a ReceiveMessage call will wait for a message to arrive (long polling) before returning"
default = "20"
}

variable "visibility_timeout_seconds" {
description = "The visibility timeout for the queue"
Expand Down

0 comments on commit 8ebeab8

Please sign in to comment.