Skip to content

Commit 15d3de7

Browse files
Merge pull request #17 from fvazquez-caylent/CA-10-Tag-based-authorization
CA-10 Tag based authorization
2 parents 70f83a3 + 18e9bd9 commit 15d3de7

File tree

8 files changed

+37
-7
lines changed

8 files changed

+37
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Tamr Terraform Template Repo
22

3+
## v2.1.0 - July 12nd 2021
4+
* 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`
7+
38
## v2.0.0 - June 30th 2021
49
* Accepts a list of security groups
510
* Returns a list of ports used by RDS

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This terraform module will create:
5454
| subnet\_group\_name | The name of the subnet group to add the RDS instance to | `string` | n/a | yes |
5555
| vpc\_id | VPC ID for the rds security group | `string` | n/a | yes |
5656
| additional\_cidrs | Additional CIDR to connect to RDS Postgres instance | `list(string)` | `[]` | no |
57-
| additional\_tags | Additional tags to set on the RDS instance | `map(string)` | `{}` | no |
57+
| additional\_tags | [DEPRECATED: Use `tags` instead] Additional tags to set on the RDS instance. | `map(string)` | `{}` | no |
5858
| allocated\_storage | Allocate storage | `number` | `20` | no |
5959
| apply\_immediately | Apply immediately, do not set this to true for production | `bool` | `false` | no |
6060
| backup\_retention\_period | Backup retention period in days | `number` | `14` | no |
@@ -72,6 +72,7 @@ This terraform module will create:
7272
| security\_group\_name | Name for the security group for the rds instance | `string` | `"tamr_rds_sg"` | no |
7373
| skip\_final\_snapshot | Skip final snapshot | `bool` | `true` | no |
7474
| storage\_type | Storage type (e.g. gp2, io1) | `string` | `"gp2"` | no |
75+
| tags | A map of tags to add to all resources. Replaces `additional_tags`. | `map(string)` | `{}` | no |
7576
| username | The username for the master DB user. | `string` | `"tamr"` | no |
7677

7778
## Outputs

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
2.1.0

examples/minimal/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ No provider.
1717
| subnet\_ids | List of at least 2 subnets in different AZs for DB subnet group | `list(string)` | n/a | yes |
1818
| vpc\_id | VPC ID of network. | `string` | n/a | yes |
1919
| egress\_cidr\_blocks | CIDR blocks to attach to security groups for egress | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
20+
| tags | A map of tags to add to all resources created by this example. | `map(string)` | <pre>{<br> "Author": "Tamr",<br> "Environment": "Example"<br>}</pre> | no |
2021

2122
## Outputs
2223

examples/minimal/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +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+
tags = var.tags
1617
}
1718

1819
module "sg-ports" {
@@ -29,4 +30,5 @@ module "rds-postgres-sg" {
2930
sg_name_prefix = var.name_prefix
3031
egress_protocol = "all"
3132
ingress_protocol = "tcp"
33+
tags = var.tags
3234
}

examples/minimal/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ variable "egress_cidr_blocks" {
2727
type = list(string)
2828
default = ["0.0.0.0/0"]
2929
}
30+
31+
variable "tags" {
32+
type = map(string)
33+
description = "A map of tags to add to all resources created by this example."
34+
default = {
35+
Author = "Tamr"
36+
Environment = "Example"
37+
}
38+
}
39+

main.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +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
15+
tags = local.effective_tags
1116
}
1217

1318
resource "aws_db_instance" "rds_postgres" {
@@ -41,7 +46,7 @@ resource "aws_db_instance" "rds_postgres" {
4146
apply_immediately = var.apply_immediately
4247

4348
copy_tags_to_snapshot = var.copy_tags_to_snapshot
44-
tags = var.additional_tags
49+
tags = local.effective_tags
4550

4651
lifecycle {
4752
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)