diff --git a/main.tf b/main.tf index 396afb323..aea78dcdb 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 = 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 @@ -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 856e2a25c..8fc08f4bd 100644 --- a/variables.tf +++ b/variables.tf @@ -10,6 +10,18 @@ variable "name" { default = "" } +variable "database_subnet_group_name" { + description = "Name to be used on DB Subnet Group resource as identifier" + type = string + 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