From 89a5763625cc60ad1d8b9afd13cfda916e88996a Mon Sep 17 00:00:00 2001 From: Win Gutmann <54120202+winthropgutmann-ef@users.noreply.github.com> Date: Mon, 18 Mar 2024 20:06:31 -0400 Subject: [PATCH] fix: Separate `db_instance_tags` from merged `tags` sub-module input (#544) Co-authored-by: Bryant Biggs --- .pre-commit-config.yaml | 2 +- main.tf | 3 ++- modules/db_instance/README.md | 1 + modules/db_instance/main.tf | 2 +- modules/db_instance/variables.tf | 6 ++++++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 395404e8..ade44ffa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.88.0 + rev: v1.88.2 hooks: - id: terraform_fmt - id: terraform_docs diff --git a/main.tf b/main.tf index f06f12f4..31fefcd9 100644 --- a/main.tf +++ b/main.tf @@ -151,7 +151,8 @@ module "db_instance" { restore_to_point_in_time = var.restore_to_point_in_time s3_import = var.s3_import - tags = merge(var.tags, var.db_instance_tags) + db_instance_tags = var.db_instance_tags + tags = var.tags } module "db_instance_role_association" { diff --git a/modules/db_instance/README.md b/modules/db_instance/README.md index 0edf1309..df849af2 100644 --- a/modules/db_instance/README.md +++ b/modules/db_instance/README.md @@ -54,6 +54,7 @@ No modules. | [create\_cloudwatch\_log\_group](#input\_create\_cloudwatch\_log\_group) | Determines whether a CloudWatch log group is created for each `enabled_cloudwatch_logs_exports` | `bool` | `false` | no | | [create\_monitoring\_role](#input\_create\_monitoring\_role) | Create IAM role with a defined name that permits RDS to send enhanced monitoring metrics to CloudWatch Logs. | `bool` | `false` | no | | [custom\_iam\_instance\_profile](#input\_custom\_iam\_instance\_profile) | RDS custom iam instance profile | `string` | `null` | no | +| [db\_instance\_tags](#input\_db\_instance\_tags) | A map of additional tags for the DB instance | `map(string)` | `{}` | no | | [db\_name](#input\_db\_name) | The DB name to create. If omitted, no database is created initially | `string` | `null` | no | | [db\_subnet\_group\_name](#input\_db\_subnet\_group\_name) | Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC | `string` | `null` | no | | [delete\_automated\_backups](#input\_delete\_automated\_backups) | Specifies whether to remove automated backups immediately after the DB instance is deleted | `bool` | `true` | no | diff --git a/modules/db_instance/main.tf b/modules/db_instance/main.tf index 325d82cb..2d6765c9 100644 --- a/modules/db_instance/main.tf +++ b/modules/db_instance/main.tf @@ -132,7 +132,7 @@ resource "aws_db_instance" "this" { } } - tags = var.tags + tags = merge(var.tags, var.db_instance_tags) depends_on = [aws_cloudwatch_log_group.this] diff --git a/modules/db_instance/variables.tf b/modules/db_instance/variables.tf index 372d4529..e7fb4c33 100644 --- a/modules/db_instance/variables.tf +++ b/modules/db_instance/variables.tf @@ -323,6 +323,12 @@ variable "tags" { default = {} } +variable "db_instance_tags" { + description = "A map of additional tags for the DB instance" + type = map(string) + default = {} +} + variable "option_group_name" { description = "Name of the DB option group to associate." type = string