Skip to content

Commit

Permalink
fix[tf]: Added check - Subnet association with AZs
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabNeu committed Sep 25, 2023
1 parent 4ab0ffa commit 1fb383e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ resource "aws_subnet" "public_subnets" {
count = length(var.public_subnets)
vpc_id = aws_vpc.vpc.id
cidr_block = var.public_subnets[count.index]
availability_zone = data.aws_availability_zones.available_zones.names[count.index]
availability_zone = data.aws_availability_zones.available_zones.names[count.index % length(data.aws_availability_zones.available_zones.names)]


tags = {
Name = "${var.env}-public-subnet-${count.index}"
Expand All @@ -65,7 +66,7 @@ resource "aws_subnet" "private_subnets" {
count = length(var.private_subnets)
vpc_id = aws_vpc.vpc.id
cidr_block = var.private_subnets[count.index]
availability_zone = data.aws_availability_zones.available_zones.names[count.index]
availability_zone = data.aws_availability_zones.available_zones.names[count.index % length(data.aws_availability_zones.available_zones.names)]

tags = {
Name = "${var.env}-private-subnet-${count.index}"
Expand Down

0 comments on commit 1fb383e

Please sign in to comment.