I am using aws vpc module
and defined below variables.
I am trying to understand use of element
and why the cidr_block
is calculated as below:
element(concat(var.public_cidr_blocks, [""]), count.index)
Below are the variable
and resource block.
variable "public_cidr_blocks" {
type = list(string)
default = [
"182.10.10.0/24",
"182.10.20.0/24"
]
}
variable "availability_zones" {
type = list(string)
default = [
"us-east-2a",
"us-east-2b"
]
}
resource "aws_subnet" "aws_public_subnets" {
vpc_id = aws_vpc.myvpc.id
cidr_block = element(concat(var.public_cidr_blocks, [""]), count.index)
availability_zone = element(var.availability_zones, count.index)
map_public_ip_on_launch = true
count = length(var.public_cidr_blocks)
}
My question is why [""]
has to be concated here
in the elements function.