I am getting the 3 existing subnet ids using data resource as below
data "aws_subnet" "AZA" {
vpc_id = var.vpc_id
filter {
name = "tag:Name"
values = ["my-subnet-1a"]
}
}
Similarly I’m getting AZB and AZC as well. Now I need to pass these subnet ids to aws_network_interface resource which has count attribute.
resource "aws_network_interface" "my_network_interface" {
count = 3
private_ips = [var.private_ips[count.index]]
subnet_id = ???
How do I pass subnet_id in each iteration?
2
Answers
Had a similar situation. I have used locals to concat the subnet ids
The better way is to use aws_subnets (not
aws_subnet
):then