Skip to content

Commit 047bae8

Browse files
CA-10 Deprecates additional_tags in favor of tags var
1 parent dd6d908 commit 047bae8

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Tamr Terraform Template Repo
22

3-
## v2.1.0 - July 9th 2021
3+
## v2.1.0 - July 12nd 2021
44
* Adds tags for RDS Subnet Group.
5+
* Adds new variable `tags` to set tags for all resources
6+
* Deprecates `additional_tags` in favor of `tags`
57

68
## v2.0.0 - June 30th 2021
79
* Accepts a list of security groups

examples/minimal/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ module "rds_postgres" {
88
username = "exampleUsername"
99
password = "examplePassword" #tfsec:ignore:GEN003
1010

11-
vpc_id = var.vpc_id
12-
subnet_group_name = "example_subnet_group"
11+
vpc_id = var.vpc_id
12+
subnet_group_name = "example_subnet_group"
1313
# Network requirement: DB subnet group needs a subnet in at least two Availability Zones
1414
rds_subnet_ids = var.subnet_ids
1515
security_group_ids = module.rds-postgres-sg.security_group_ids
16-
additional_tags = var.additional_tags
16+
tags = var.tags
1717
}
1818

1919
module "sg-ports" {
@@ -30,5 +30,5 @@ module "rds-postgres-sg" {
3030
sg_name_prefix = var.name_prefix
3131
egress_protocol = "all"
3232
ingress_protocol = "tcp"
33-
additional_tags = var.additional_tags
33+
tags = var.tags
3434
}

examples/minimal/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ variable "egress_cidr_blocks" {
2828
default = ["0.0.0.0/0"]
2929
}
3030

31-
variable "additional_tags" {
31+
variable "tags" {
3232
type = map(string)
3333
description = "Additional tags for resources created by this example"
3434
default = {

main.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
locals {
2+
effective_tags = length(var.tags) > 0 ? var.tags : var.additional_tags
3+
}
4+
15
resource "aws_db_parameter_group" "rds_postgres_pg" {
26
name = var.parameter_group_name
37
family = var.parameter_group_family
48
description = "TAMR RDS parameter group"
5-
tags = var.additional_tags
9+
tags = local.effective_tags
610
}
711

812
resource "aws_db_subnet_group" "rds_postgres_subnet_group" {
913
name = var.subnet_group_name
1014
subnet_ids = var.rds_subnet_ids
11-
tags = var.additional_tags
15+
tags = local.effective_tags
1216
}
1317

1418
resource "aws_db_instance" "rds_postgres" {
@@ -42,7 +46,7 @@ resource "aws_db_instance" "rds_postgres" {
4246
apply_immediately = var.apply_immediately
4347

4448
copy_tags_to_snapshot = var.copy_tags_to_snapshot
45-
tags = var.additional_tags
49+
tags = local.effective_tags
4650

4751
lifecycle {
4852
ignore_changes = [password]

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,14 @@ variable "copy_tags_to_snapshot" {
104104
}
105105

106106
variable "additional_tags" {
107-
description = "Additional tags to set on the RDS instance"
108107
type = map(string)
108+
description = "[DEPRECATED: Use `tags` instead] Additional tags to set on the RDS instance."
109+
default = {}
110+
}
111+
112+
variable "tags" {
113+
type = map(string)
114+
description = "A map of tags to add to all resources. Replaces `additional_tags`."
109115
default = {}
110116
}
111117

0 commit comments

Comments
 (0)