I need to compose a list of subnet ids for load balancer. At the top level, I have variable "selected_subnets" to save the indices (i.e. not all subnets should be selected).
terraform.tfvars.json
{
"selected_subnets": ["0", "2", "5"],
}
To refer subnet id individually, I can do.
data.aws_subnet.internal_public[count.index].id
I want to compose them into a list so that I can assign to attribute "subnets" of load balancer.
resource "aws_lb" {
subnets = ??? /* the list of ids of all selected subnets */