From 74f69284ad9e352653fd9b8535b6d42c16a17787 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Mon, 24 Oct 2022 22:19:15 -0300 Subject: [PATCH] Update sqs module Co-authored-by: Ezequiel Bellver --- terraform/modules/sqs/main.tf | 22 ++++++------- terraform/modules/sqs/variables.tf | 51 ++++++++++++++++++++++++++++++ terraform/modules/sqs/versions.tf | 10 ++++++ terraform/organization/sqs.tf | 12 +++++++ 4 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 terraform/modules/sqs/variables.tf create mode 100644 terraform/modules/sqs/versions.tf diff --git a/terraform/modules/sqs/main.tf b/terraform/modules/sqs/main.tf index 1408370..dbb5a33 100644 --- a/terraform/modules/sqs/main.tf +++ b/terraform/modules/sqs/main.tf @@ -2,16 +2,14 @@ # Amazon Simple Queue Service # ------------------------------------------------------------------------------ -# resource "aws_sqs_queue" "terraform_queue" { -# name = var.name -# delay_seconds = 90 -# max_message_size = 2048 -# message_retention_seconds = 86400 -# receive_wait_time_seconds = 10 -# redrive_policy = jsonencode({ -# deadLetterTargetArn = aws_sqs_queue.terraform_queue_deadletter.arn -# maxReceiveCount = 4 -# }) +resource "aws_sqs_queue" "terraform_queue" { + name = var.name + delay_seconds = var.delay_seconds + max_message_size = var.max_message_size + message_retention_seconds = var.message_retention_seconds + receive_wait_time_seconds = var.receive_wait_time_seconds + fifo_queue = var.fifo_queue + content_based_deduplication = var.content_based_deduplication -# tags = var.tags -# } + tags = var.tags +} diff --git a/terraform/modules/sqs/variables.tf b/terraform/modules/sqs/variables.tf new file mode 100644 index 0000000..23348fa --- /dev/null +++ b/terraform/modules/sqs/variables.tf @@ -0,0 +1,51 @@ +# ------------------------------------------------------------------------------ +# Amazon Simple Queue Service variables +# ------------------------------------------------------------------------------ + +variable "name" { + description = "This is the human-readable name of the queue. If omitted, Terraform will assign a random name." + type = string + default = null +} + +variable "message_retention_seconds" { + description = "The number of seconds Amazon SQS retains a message. Integer representing seconds, from 60 (1 minute) to 1209600 (14 days)" + type = number + default = 345600 +} + +variable "max_message_size" { + description = "The limit of how many bytes a message can contain before Amazon SQS rejects it. An integer from 1024 bytes (1 KiB) up to 262144 bytes (256 KiB)" + type = number + default = 262144 +} + +variable "delay_seconds" { + description = "The time in seconds that the delivery of all messages in the queue will be delayed. An integer from 0 to 900 (15 minutes)" + type = number + default = 0 +} + +variable "receive_wait_time_seconds" { + description = "The time for which a ReceiveMessage call will wait for a message to arrive (long polling) before returning. An integer from 0 to 20 (seconds)" + type = number + default = 0 +} + +variable "fifo_queue" { + description = "Boolean designating a FIFO queue" + type = bool + default = false +} + +variable "content_based_deduplication" { + description = "Enables content-based deduplication for FIFO queues" + type = bool + default = false +} + +variable "tags" { + description = "A mapping of tags to assign to all resources" + type = map(string) + default = {} +} \ No newline at end of file diff --git a/terraform/modules/sqs/versions.tf b/terraform/modules/sqs/versions.tf new file mode 100644 index 0000000..bceb8d0 --- /dev/null +++ b/terraform/modules/sqs/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0.6" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 4.10.0" + } + } +} diff --git a/terraform/organization/sqs.tf b/terraform/organization/sqs.tf index 8b13789..9d39096 100644 --- a/terraform/organization/sqs.tf +++ b/terraform/organization/sqs.tf @@ -1 +1,13 @@ +module "sqs" { + source = "../modules/sqs" + providers = { + aws = aws.aws + } + + name = "AWS-SQS-g3" + + tags = { + name = "SQS" + } +}