Как правильно прописать id созданых subnets в elb terraform?
data "aws_availability_zones" "available" {}
locals {
az_names = data.aws_availability_zones.available.names
}
resource "aws_subnet" "wpl_public_subnet" {
for_each = { for index, az_name in local.az_names : index => az_name }
vpc_id = aws_vpc.wpl_vpc.id
cidr_block = cidrsubnet(var.vpc_cidr, 8, each.key + 10)
availability_zone = local.az_names[each.key]
map_public_ip_on_launch = true
tags = {
Name = "WPL-PublicSubnet"
CreatedBy = var.created_by
}
}
resource "aws_elb" "wpl_elb" {
name = "terraform-elb"
security_groups = [aws_security_group.wpl_sg.id]
subnets = [for_each aws_subnet.wpl_public_subnet : each.value.id]
listener {
instance_port = 80
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
cross_zone_load_balancing = true
idle_timeout = 400
connection_draining = true
connection_draining_timeout = 400
tags = {
Name = "WPL-ELB"
}
}
гуглил, толкового примера не нашел
subnets = [aws_subnet.wpl_public_subnet[*].id]
так не работает :(
Может нужно aws_subnet.wpl_public_subnet[*].id заюзать как аутпут модуля и тогда можно передать списком?