From bc28d115760f22f37d3844f0f72a5912e253e349 Mon Sep 17 00:00:00 2001 From: Juho Majasaari Date: Tue, 31 Aug 2021 16:30:34 +0300 Subject: [PATCH 1/4] feat: Add support for naming and tagging of ElastiCache subnet group --- README.md | 4 +++- main.tf | 10 +++++++++- variables.tf | 12 ++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 45a191af8..31c012146 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.28 | +| [aws](#provider\_aws) | 3.56.0 | ## Modules @@ -346,6 +346,8 @@ No modules. | [elasticache\_outbound\_acl\_rules](#input\_elasticache\_outbound\_acl\_rules) | Elasticache subnets outbound network ACL rules | `list(map(string))` |
[
{
"cidr_block": "0.0.0.0/0",
"from_port": 0,
"protocol": "-1",
"rule_action": "allow",
"rule_number": 100,
"to_port": 0
}
]
| no | | [elasticache\_route\_table\_tags](#input\_elasticache\_route\_table\_tags) | Additional tags for the elasticache route tables | `map(string)` | `{}` | no | | [elasticache\_subnet\_assign\_ipv6\_address\_on\_creation](#input\_elasticache\_subnet\_assign\_ipv6\_address\_on\_creation) | Assign IPv6 address on elasticache subnet, must be disabled to change IPv6 CIDRs. This is the IPv6 equivalent of map\_public\_ip\_on\_launch | `bool` | `null` | no | +| [elasticache\_subnet\_group\_name](#input\_elasticache\_subnet\_group\_name) | Name of elasticache subnet group | `string` | `null` | no | +| [elasticache\_subnet\_group\_tags](#input\_elasticache\_subnet\_group\_tags) | Additional tags for the elasticache subnet group | `map(string)` | `{}` | no | | [elasticache\_subnet\_ipv6\_prefixes](#input\_elasticache\_subnet\_ipv6\_prefixes) | Assigns IPv6 elasticache subnet id based on the Amazon provided /56 prefix base 10 integer (0-256). Must be of equal length to the corresponding IPv4 subnet list | `list(string)` | `[]` | no | | [elasticache\_subnet\_suffix](#input\_elasticache\_subnet\_suffix) | Suffix to append to elasticache subnets name | `string` | `"elasticache"` | no | | [elasticache\_subnet\_tags](#input\_elasticache\_subnet\_tags) | Additional tags for the elasticache subnets | `map(string)` | `{}` | no | diff --git a/main.tf b/main.tf index d66d8311e..430a81fed 100644 --- a/main.tf +++ b/main.tf @@ -569,9 +569,17 @@ resource "aws_subnet" "elasticache" { resource "aws_elasticache_subnet_group" "elasticache" { count = var.create_vpc && length(var.elasticache_subnets) > 0 && var.create_elasticache_subnet_group ? 1 : 0 - name = var.name + name = coalesce(var.elasticache_subnet_group_name, var.name) description = "ElastiCache subnet group for ${var.name}" subnet_ids = aws_subnet.elasticache.*.id + + tags = merge( + { + "Name" = format("%s", coalesce(var.elasticache_subnet_group_name, var.name)) + }, + var.tags, + var.elasticache_subnet_group_tags, + ) } ################################################################################ diff --git a/variables.tf b/variables.tf index 52c68b1ed..584c6bcc0 100644 --- a/variables.tf +++ b/variables.tf @@ -508,6 +508,18 @@ variable "redshift_subnet_group_tags" { default = {} } +variable "elasticache_subnet_group_name" { + description = "Name of elasticache subnet group" + type = string + default = null +} + +variable "elasticache_subnet_group_tags" { + description = "Additional tags for the elasticache subnet group" + type = map(string) + default = {} +} + variable "elasticache_subnet_tags" { description = "Additional tags for the elasticache subnets" type = map(string) From ee4f18cb94ccba9ce0674b09afe89ff09097cb58 Mon Sep 17 00:00:00 2001 From: Juho Majasaari Date: Tue, 31 Aug 2021 16:44:23 +0300 Subject: [PATCH 2/4] feat: Add support for naming Redshift subnet group --- README.md | 1 + main.tf | 4 ++-- variables.tf | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31c012146..525c15ccf 100644 --- a/README.md +++ b/README.md @@ -434,6 +434,7 @@ No modules. | [redshift\_outbound\_acl\_rules](#input\_redshift\_outbound\_acl\_rules) | Redshift subnets outbound network ACL rules | `list(map(string))` |
[
{
"cidr_block": "0.0.0.0/0",
"from_port": 0,
"protocol": "-1",
"rule_action": "allow",
"rule_number": 100,
"to_port": 0
}
]
| no | | [redshift\_route\_table\_tags](#input\_redshift\_route\_table\_tags) | Additional tags for the redshift route tables | `map(string)` | `{}` | no | | [redshift\_subnet\_assign\_ipv6\_address\_on\_creation](#input\_redshift\_subnet\_assign\_ipv6\_address\_on\_creation) | Assign IPv6 address on redshift subnet, must be disabled to change IPv6 CIDRs. This is the IPv6 equivalent of map\_public\_ip\_on\_launch | `bool` | `null` | no | +| [redshift\_subnet\_group\_name](#input\_redshift\_subnet\_group\_name) | Name of redshift subnet group | `string` | `null` | no | | [redshift\_subnet\_group\_tags](#input\_redshift\_subnet\_group\_tags) | Additional tags for the redshift subnet group | `map(string)` | `{}` | no | | [redshift\_subnet\_ipv6\_prefixes](#input\_redshift\_subnet\_ipv6\_prefixes) | Assigns IPv6 redshift subnet id based on the Amazon provided /56 prefix base 10 integer (0-256). Must be of equal length to the corresponding IPv4 subnet list | `list(string)` | `[]` | no | | [redshift\_subnet\_suffix](#input\_redshift\_subnet\_suffix) | Suffix to append to redshift subnets name | `string` | `"redshift"` | no | diff --git a/main.tf b/main.tf index 430a81fed..58d202813 100644 --- a/main.tf +++ b/main.tf @@ -525,13 +525,13 @@ resource "aws_subnet" "redshift" { resource "aws_redshift_subnet_group" "redshift" { count = var.create_vpc && length(var.redshift_subnets) > 0 && var.create_redshift_subnet_group ? 1 : 0 - name = lower(var.name) + name = lower(coalesce(var.redshift_subnet_group_name, var.name)) description = "Redshift subnet group for ${var.name}" subnet_ids = aws_subnet.redshift.*.id tags = merge( { - "Name" = format("%s", var.name) + "Name" = format("%s", coalesce(var.redshift_subnet_group_name, var.name)) }, var.tags, var.redshift_subnet_group_tags, diff --git a/variables.tf b/variables.tf index 584c6bcc0..ddd592534 100644 --- a/variables.tf +++ b/variables.tf @@ -502,6 +502,12 @@ variable "redshift_subnet_tags" { default = {} } +variable "redshift_subnet_group_name" { + description = "Name of redshift subnet group" + type = string + default = null +} + variable "redshift_subnet_group_tags" { description = "Additional tags for the redshift subnet group" type = map(string) From 466254162e4614529340453d0b5d044d7e82f3ab Mon Sep 17 00:00:00 2001 From: Juho Majasaari Date: Tue, 31 Aug 2021 17:10:17 +0300 Subject: [PATCH 3/4] fix: Update AWS provider version to support tags for elasticache_subnet_group --- versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.tf b/versions.tf index 7045f6d16..506304126 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.28" + version = ">= 3.38" } } } From 46f0b5fdf0e3a7a8c277e8b74a56bce2637a22b5 Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Tue, 31 Aug 2021 16:15:40 +0200 Subject: [PATCH 4/4] Fixed docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 525c15ccf..3977adf24 100644 --- a/README.md +++ b/README.md @@ -189,13 +189,13 @@ It is possible to integrate this VPC module with [terraform-aws-transit-gateway | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.12.31 | -| [aws](#requirement\_aws) | >= 3.28 | +| [aws](#requirement\_aws) | >= 3.38 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | 3.56.0 | +| [aws](#provider\_aws) | >= 3.38 | ## Modules