I have aws_subnet resource which looks as below:
resource "aws_subnet" "public_subnets" {
cidr_block = element(concat(var.psubnets, [""]), count.index)
availability_zone = element(var.azs, count.index)
count = length(var.psubnets)
}
Here, how to update availability_zone = element(var.azs, count.index) to account for the situation when
len.subnets > len.azs
The modulus operator should help you account for this:
For example if the
len(var.azs)value is3, and you had7subnets, you would get the following: