From 611ce00b3778b5aaaaa32e71c35c74309889491b Mon Sep 17 00:00:00 2001 From: Jan Sebastian Siwy Date: Sat, 21 Sep 2024 19:58:30 +0200 Subject: [PATCH 1/2] Add support for resource-specific tags --- CHANGELOG.md | 5 +++++ README.md | 5 ----- main.tf | 14 +++++++------ variables.tf | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00b003a..f298fe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# NOTE: CHANGELOG.md is deprecated + +After the release of v1.1.0, please see the [GitHub release notes](https://github.com/babbel/terraform-aws-sns-to-rollbar/releases) +for the module in order to view the most up-to-date changes. + # CHANGELOG.md ## v1.1.0 diff --git a/README.md b/README.md index cd7c7a6..86271f6 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,5 @@ module "sns-to-rollbar" { environment = "test" level = "debug" - - tags = { - app = "some-service" - env = "test" - } } ``` diff --git a/main.tf b/main.tf index 36b073e..a6a3efd 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,7 @@ resource "aws_sns_topic" "this" { name = var.name - tags = var.tags + tags = merge(var.default_tags, var.sns_topic_tags) } resource "aws_sns_topic_subscription" "sqs-queue" { @@ -15,7 +15,7 @@ resource "aws_sns_topic_subscription" "sqs-queue" { resource "aws_sqs_queue" "this" { name = var.name - tags = var.tags + tags = merge(var.default_tags, var.sqs_queue_tags) } data "aws_iam_policy_document" "sqs-queue-consume" { @@ -73,7 +73,7 @@ resource "aws_pipes_pipe" "this" { } } - tags = var.tags + tags = merge(var.default_tags, var.pipes_pipe_tags) depends_on = [ aws_iam_role_policy.pipes-pipe-sqs-queue-consume, @@ -84,7 +84,8 @@ resource "aws_pipes_pipe" "this" { resource "aws_iam_role" "pipes-pipe" { name = "pipes-${var.name}" assume_role_policy = data.aws_iam_policy_document.pipes-assume-role.json - tags = var.tags + + tags = merge(var.default_tags, var.pipes_pipe_iam_role_tags) } data "aws_iam_policy_document" "pipes-assume-role" { @@ -284,7 +285,7 @@ resource "aws_sfn_state_machine" "this" { }) ) - tags = var.tags + tags = merge(var.default_tags, var.sfn_state_machine_tags) } data "aws_iam_policy_document" "sfn-state-machine-start-execution" { @@ -297,7 +298,8 @@ data "aws_iam_policy_document" "sfn-state-machine-start-execution" { resource "aws_iam_role" "sfn-state-machine" { name = "step-function-${var.name}" assume_role_policy = data.aws_iam_policy_document.states.json - tags = var.tags + + tags = merge(var.default_tags, var.sfn_state_machine_iam_role_tags) } data "aws_iam_policy_document" "states" { diff --git a/variables.tf b/variables.tf index 503b6e1..f1d0659 100644 --- a/variables.tf +++ b/variables.tf @@ -1,3 +1,12 @@ +variable "default_tags" { + type = map(string) + default = {} + + description = < Date: Sat, 21 Sep 2024 20:13:14 +0200 Subject: [PATCH 2/2] Update main.tf --- _test/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_test/main.tf b/_test/main.tf index a3f93ee..d68ba61 100644 --- a/_test/main.tf +++ b/_test/main.tf @@ -16,7 +16,7 @@ module "sns-to-rollbar-with-json-key" { environment = "test" level = "debug" - tags = { + default_tags = { app = "some-service" env = "test" } @@ -34,7 +34,7 @@ module "sns-to-rollbar-without-json-key" { environment = "test" level = "debug" - tags = { + default_tags = { app = "some-service" env = "test" }