From 3301f75022afa7430d3821ee9ddf22b615581096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emir=20=C3=96zbir?= Date: Tue, 8 Oct 2019 20:37:08 +0300 Subject: [PATCH 1/2] Bugs are fixed at sqs module --- examples/sqs/backend.tf | 7 ------- examples/sqs/main.tf | 7 ++++++- globalvariable/main.tf | 3 ++- sqs/backend.tf | 13 ------------- sqs/main.tf | 40 +++++++++++++++++++++------------------- sqs/vars.tf | 15 +++++++++------ 6 files changed, 38 insertions(+), 47 deletions(-) delete mode 100644 examples/sqs/backend.tf delete mode 100644 sqs/backend.tf diff --git a/examples/sqs/backend.tf b/examples/sqs/backend.tf deleted file mode 100644 index 62c2144..0000000 --- a/examples/sqs/backend.tf +++ /dev/null @@ -1,7 +0,0 @@ - terraform { - backend "s3" { - bucket = "sqs" ## vpc_bucket, terra_bucket .. - key = "sqsterraform/base.tfstate" - } - } - diff --git a/examples/sqs/main.tf b/examples/sqs/main.tf index e12a909..74403a5 100644 --- a/examples/sqs/main.tf +++ b/examples/sqs/main.tf @@ -1,11 +1,16 @@ + + module "my_sqs" { source = "../../sqs" - queue_names = ["osman1"] + queue_names = ["q1", "q2", "q3"] tag_name = "tag" tag_deployment ="deployment" tag_kubernetes_cluster = "k8s" tag_organisation = "org" tag_project = "project" tag_deployment_code = "deployment" + aws_region = "" + aws_accountId = "" + } diff --git a/globalvariable/main.tf b/globalvariable/main.tf index ec83082..633be33 100644 --- a/globalvariable/main.tf +++ b/globalvariable/main.tf @@ -9,4 +9,5 @@ output "global" { Project = "${var.tag_project}" } -} \ No newline at end of file +} + diff --git a/sqs/backend.tf b/sqs/backend.tf deleted file mode 100644 index 27f29e7..0000000 --- a/sqs/backend.tf +++ /dev/null @@ -1,13 +0,0 @@ - terraform { - backend "s3" { - region = "us-east-2"#us-east-2, eu-west-1 - bucket = "sqs_state" ## vpc_bucket, terra_bucket .. - profile = "profile" - key = "sqs_state/base.tfstate" - } - } - - provider "aws" { - profile = "profile" - region = "region" #us-east-2 - } diff --git a/sqs/main.tf b/sqs/main.tf index 166364b..f658a4b 100644 --- a/sqs/main.tf +++ b/sqs/main.tf @@ -1,7 +1,6 @@ - module "queue_map" { source = "../mapping" - queue_names = "${var.queue_names}" + object_names = "${var.queue_names}" } @@ -16,20 +15,8 @@ module "global" { } -resource "aws_sqs_queue" "dead_letter_queue" { - count = "${module.queue_map.queue_names}" - name = "${lookup(module.queue_map.dead_letter_queue_mappings[count.index],"queue_name")}" - delay_seconds = "${lookup(module.queue_map.dead_letter_queue_mappings[count.index],"delaysec")}" - max_message_size = "${lookup(module.queue_map.dead_letter_queue_mappings[count.index],"max_message_size")}" - message_retention_seconds = "${lookup(module.queue_map.dead_letter_queue_mappings[count.index],"mes_ret_sec")}" - receive_wait_time_seconds = "${lookup(module.queue_map.dead_letter_queue_mappings[count.index],"rec_wait_time_sec")}" - fifo_queue = "${lookup(module.queue_map.dead_letter_queue_mappings[count.index],"fifo_queue")}" - - tags = "${module.global.tags}" -} - resource "aws_sqs_queue" "queue" { - count = "${module.queue_map.queue_names}" + count = "${length(var.queue_names)}" name = "${lookup(module.queue_map.queue_mappings[count.index],"queue_name")}" delay_seconds = "${lookup(module.queue_map.queue_mappings[count.index],"delaysec")}" @@ -37,15 +24,30 @@ resource "aws_sqs_queue" "queue" { message_retention_seconds = "${lookup(module.queue_map.queue_mappings[count.index],"mes_ret_sec")}" receive_wait_time_seconds = "${lookup(module.queue_map.queue_mappings[count.index],"rec_wait_time_sec")}" fifo_queue = "${lookup(module.queue_map.queue_mappings[count.index],"fifo_queue")}" - tags = "${module.global.tags}" - + tags = "${module.global.global}" + redrive_policy = < Date: Wed, 9 Oct 2019 01:41:46 +0300 Subject: [PATCH 2/2] test-release --- examples/sqs/main.tf | 2 +- mapping/mapping.tf | 43 +++++++++++++++++++++++++++++++++++++++++++ mapping/test.tf | 19 ------------------- sqs/main.tf | 1 - 4 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 mapping/mapping.tf delete mode 100644 mapping/test.tf diff --git a/examples/sqs/main.tf b/examples/sqs/main.tf index 74403a5..feeae5a 100644 --- a/examples/sqs/main.tf +++ b/examples/sqs/main.tf @@ -1,7 +1,7 @@ module "my_sqs" { - source = "../../sqs" + source = "git::https://github.com/kloia/terraform-modules//sqs?ref=v0.0.15sqs" queue_names = ["q1", "q2", "q3"] tag_name = "tag" tag_deployment ="deployment" diff --git a/mapping/mapping.tf b/mapping/mapping.tf new file mode 100644 index 0000000..7d6753d --- /dev/null +++ b/mapping/mapping.tf @@ -0,0 +1,43 @@ + +variable "object_names" { + type = "list" +} + +locals { + queue_names = "${var.object_names}" +} + +resource "null_resource" "queue_mappings" { + count = "${length(local.queue_names)}" + + triggers { + queue_name = "${element(local.queue_names, count.index)}" + max_message_size=262144 + vis_timeout_sec=43200 + mes_ret_sec=1209600 + rec_wait_time_sec=0 + fifo_queue=false + delaysec = 90 + } +} +output "queue_mappings" { + value = "${null_resource.queue_mappings.*.triggers}" +} + +resource "null_resource" "dead_letter_queue_mappings" { + count = "${length(local.queue_names)}" + + triggers { + queue_name = "${element(local.queue_names, count.index)}_dlx" + max_message_size=262144 + vis_timeout_sec=43200 + mes_ret_sec=1209600 + rec_wait_time_sec=0 + fifo_queue=false + delaysec = 90 + + } +} +output "dead_letter_queue_mappings" { + value = "${null_resource.dead_letter_queue_mappings.*.triggers}" +} \ No newline at end of file diff --git a/mapping/test.tf b/mapping/test.tf deleted file mode 100644 index f36f104..0000000 --- a/mapping/test.tf +++ /dev/null @@ -1,19 +0,0 @@ -locals { - queue_names = ["q1", "q2", "q3"] -} - -resource "null_resource" "queue_mappings" { - count = "${length(local.queue_names)}" - - triggers { - queue_name = "${element(local.queue_names, count.index)}" - max_message_size=262144 - vis_timeout_sec=43200 - mes_ret_sec=1209600 - rec_wait_time_sec=0 - fifo_queue=false - } -} -output "queue_mappings" { - value = "${null_resource.queue_mappings.*.triggers}" -} \ No newline at end of file diff --git a/sqs/main.tf b/sqs/main.tf index f658a4b..b075111 100644 --- a/sqs/main.tf +++ b/sqs/main.tf @@ -12,7 +12,6 @@ module "global" { tag_organisation = "${var.tag_organisation}" tag_project = "${var.tag_project}" tag_deployment_code = "${var.tag_deployment_code}" - } resource "aws_sqs_queue" "queue" {