Skip to content

Commit e667ac3

Browse files
committed
Changed aws_db_subnet_group to take in append name from new cidr_name variable
1 parent 5ae5422 commit e667ac3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ resource "aws_vpc" "this" {
3838
var.vpc_tags,
3939
)
4040

41-
lifecycle {
41+
lifecycle {
4242
ignore_changes = [
4343
tags
4444
]
@@ -393,13 +393,13 @@ resource "aws_subnet" "database" {
393393
resource "aws_db_subnet_group" "database" {
394394
count = var.create_vpc && length(var.database_subnets) > 0 && var.create_database_subnet_group ? 1 : 0
395395

396-
name = lower(var.name)
396+
name = lower("${var.name}-${var.cidr_name}")
397397
description = "Database subnet group for ${var.name}"
398398
subnet_ids = aws_subnet.database.*.id
399399

400400
tags = merge(
401401
{
402-
"Name" = format("%s", var.name)
402+
"Name" = format("%s", lower("${var.name}-${var.cidr_name}"))
403403
},
404404
var.tags,
405405
var.database_subnet_group_tags,

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ variable "cidr" {
1414
default = "0.0.0.0/0"
1515
}
1616

17+
variable "cidr_name" {
18+
description = "Name of cidr this vpc is managing"
19+
default = ""
20+
}
21+
1722
variable "assign_generated_ipv6_cidr_block" {
1823
description = "Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block"
1924
type = bool

0 commit comments

Comments
 (0)