From fad1657c5367994a10864d5a767aa83579289382 Mon Sep 17 00:00:00 2001 From: Andrew Replogle Date: Tue, 10 Dec 2019 10:36:14 -0600 Subject: [PATCH 1/4] Add ability to define custom DB Subnet Group Name --- main.tf | 2 +- variables.tf | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 396afb323..1decdfa7f 100644 --- a/main.tf +++ b/main.tf @@ -359,7 +359,7 @@ resource "aws_subnet" "database" { resource "aws_db_subnet_group" "database" { count = var.create_vpc && length(var.database_subnets) > 0 && var.create_database_subnet_group ? 1 : 0 - name = lower(var.name) + name = lower(var.database_subnet_group_name) description = "Database subnet group for ${var.name}" subnet_ids = aws_subnet.database.*.id diff --git a/variables.tf b/variables.tf index 856e2a25c..5a6ed14ba 100644 --- a/variables.tf +++ b/variables.tf @@ -10,6 +10,12 @@ variable "name" { default = "" } +variable "database_subnet_group_name" { + description = "Name to be used on DB Subnet Group resource as identifier" + type = string + default = "" +} + variable "cidr" { description = "The CIDR block for the VPC. Default value is a valid CIDR, but not acceptable by AWS and should be overridden" type = string From 8aa0c6250a7a6151eb260175ca274132adf9dd88 Mon Sep 17 00:00:00 2001 From: Andrew Replogle Date: Tue, 10 Dec 2019 10:42:32 -0600 Subject: [PATCH 2/4] Fix custom db group name feature to be optional instead of static --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 1decdfa7f..80247c114 100644 --- a/main.tf +++ b/main.tf @@ -359,7 +359,7 @@ resource "aws_subnet" "database" { resource "aws_db_subnet_group" "database" { count = var.create_vpc && length(var.database_subnets) > 0 && var.create_database_subnet_group ? 1 : 0 - name = lower(var.database_subnet_group_name) + name = var.database_subnet_group_name != null ? lower(var.database_subnet_group_name) : lower(var.name) description = "Database subnet group for ${var.name}" subnet_ids = aws_subnet.database.*.id From 7ef67fc3674968a3ded2d1aa59c574fd85e21b67 Mon Sep 17 00:00:00 2001 From: Andrew Replogle Date: Thu, 12 Dec 2019 11:15:16 -0600 Subject: [PATCH 3/4] set default null for db_subnet_group_name so eval happens correctly --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 5a6ed14ba..f180056da 100644 --- a/variables.tf +++ b/variables.tf @@ -13,7 +13,7 @@ variable "name" { variable "database_subnet_group_name" { description = "Name to be used on DB Subnet Group resource as identifier" type = string - default = "" + default = null } variable "cidr" { From 4d8beccf548f98890990fda52de83e1f89123730 Mon Sep 17 00:00:00 2001 From: Andrew Replogle Date: Thu, 12 Dec 2019 11:16:10 -0600 Subject: [PATCH 4/4] Add custom elasticache subnet_group name option --- main.tf | 2 +- variables.tf | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 80247c114..aea78dcdb 100644 --- a/main.tf +++ b/main.tf @@ -443,7 +443,7 @@ 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 = var.elasticache_subnet_group_name != null ? lower(var.elasticache_subnet_group_name) : lower(var.name) description = "ElastiCache subnet group for ${var.name}" subnet_ids = aws_subnet.elasticache.*.id } diff --git a/variables.tf b/variables.tf index f180056da..8fc08f4bd 100644 --- a/variables.tf +++ b/variables.tf @@ -16,6 +16,12 @@ variable "database_subnet_group_name" { default = null } +variable "elasticache_subnet_group_name" { + description = "Name to be used on Elasticache Subnet Group resource as identifier" + type = string + default = null +} + variable "cidr" { description = "The CIDR block for the VPC. Default value is a valid CIDR, but not acceptable by AWS and should be overridden" type = string