From aa05dd9ff4e1c6c79d075a671a541bd732355032 Mon Sep 17 00:00:00 2001 From: Win Gutmann <54120202+winthropgutmann-ef@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:56:13 -0400 Subject: [PATCH 1/5] creating variable db_instance_tags --- modules/db_instance/variables.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/db_instance/variables.tf b/modules/db_instance/variables.tf index 372d4529..b07c943a 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 mapping of tags to assign to all resources" + type = map(string) + default = {} +} + variable "option_group_name" { description = "Name of the DB option group to associate." type = string From 041999950a322cca1d300246f773c860dfc351ba Mon Sep 17 00:00:00 2001 From: Win Gutmann <54120202+winthropgutmann-ef@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:58:53 -0400 Subject: [PATCH 2/5] splitting tags & db_instance_tags from merge --- main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index f06f12f4..563814dd 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" { From d66999e9bbf84cc17a307311f03e1baa7b350055 Mon Sep 17 00:00:00 2001 From: Win Gutmann <54120202+winthropgutmann-ef@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:03:08 -0400 Subject: [PATCH 3/5] merge db_instance_tags and tags on rds_instance --- modules/db_instance/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] From 5b25799d95a98bb681a80a28fb1f8fba93b3f276 Mon Sep 17 00:00:00 2001 From: Win Gutmann <54120202+winthropgutmann-ef@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:31:05 -0400 Subject: [PATCH 4/5] updating the description on `db_instance_tags` variable Additional tags for the DB instance --- modules/db_instance/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/db_instance/variables.tf b/modules/db_instance/variables.tf index b07c943a..e7fb4c33 100644 --- a/modules/db_instance/variables.tf +++ b/modules/db_instance/variables.tf @@ -324,7 +324,7 @@ variable "tags" { } variable "db_instance_tags" { - description = "A mapping of tags to assign to all resources" + description = "A map of additional tags for the DB instance" type = map(string) default = {} } From b42a7bcee7077529c08b1f8e629e4080b126a2ef Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Mon, 18 Mar 2024 20:02:17 -0400 Subject: [PATCH 5/5] fix: Correct formatting --- .pre-commit-config.yaml | 2 +- main.tf | 2 +- modules/db_instance/README.md | 1 + 3 files changed, 3 insertions(+), 2 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 563814dd..31fefcd9 100644 --- a/main.tf +++ b/main.tf @@ -152,7 +152,7 @@ module "db_instance" { s3_import = var.s3_import db_instance_tags = var.db_instance_tags - tags = var.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 |