I have created 3 subnets with the for_each
syntax e.g.
resource "aws_subnet" "subnet" {
for_each = var.subnet_cidrs
vpc_id = aws_vpc.main.id
cidr_block = each.value
availability_zone = each.key
}
I now want to associate these with a route table, in past Terraform versions I could do
resource "aws_route_table_association" "public_route_assoc" {
count = length (var.subnet_cidrs)
subnet_id = element(aws_subnet.subnet.*.id, count.index)
route_table_id = element(aws_route_table.public_route.*.id, count.index)
}
but this doesn’t seem to work in 0.12 and I can’t work out the syntax for it. Is it still possible to do this in 0.12?
Thanks!