Skip to content

Commit

Permalink
Merge pull request #4 from silinternational/subnet-name
Browse files Browse the repository at this point in the history
add app_name and app_env to subnet Name tag
  • Loading branch information
briskt authored Dec 2, 2024
2 parents 01b3a7d + d75eae9 commit 215ca55
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,30 @@ locals {
}

resource "aws_subnet" "public_subnet" {
count = length(var.aws_zones)
count = length(var.aws_zones)

vpc_id = aws_vpc.vpc.id
availability_zone = element(var.aws_zones, count.index)
cidr_block = element(var.public_subnet_cidr_blocks, count.index)
ipv6_cidr_block = var.enable_ipv6 ? element(local.public_subnets, count.index) : null
availability_zone = var.aws_zones[count.index]
cidr_block = var.public_subnet_cidr_blocks[count.index]
ipv6_cidr_block = var.enable_ipv6 ? local.public_subnets[count.index] : null

tags = {
Name = "public-${element(var.aws_zones, count.index)}"
Name = "${var.app_name}-${var.app_env}-public-${element(var.aws_zones, count.index)}"
app_name = var.app_name
app_env = var.app_env
}
}

resource "aws_subnet" "private_subnet" {
count = length(var.aws_zones)
count = length(var.aws_zones)

vpc_id = aws_vpc.vpc.id
availability_zone = element(var.aws_zones, count.index)
cidr_block = element(var.private_subnet_cidr_blocks, count.index)
ipv6_cidr_block = var.enable_ipv6 ? element(local.private_subnets, count.index) : null
availability_zone = var.aws_zones[count.index]
cidr_block = var.private_subnet_cidr_blocks[count.index]
ipv6_cidr_block = var.enable_ipv6 ? local.private_subnets[count.index] : null

tags = {
Name = "private-${element(var.aws_zones, count.index)}"
Name = "${var.app_name}-${var.app_env}-private-${element(var.aws_zones, count.index)}"
app_name = var.app_name
app_env = var.app_env
}
Expand Down Expand Up @@ -232,4 +234,3 @@ resource "aws_db_subnet_group" "db_subnet_group" {
app_env = var.app_env
}
}

0 comments on commit 215ca55

Please sign in to comment.