I am really new to terraform and want to make this work. I am able to create the vpc, public subnets and get their ids, now I want to create an ec2 instance inside each of this subnet, when I try to run the ec2 module, it only create the instance inside the first subnet and ignore the other subnet(s). Here is snippet of my code.
OUTPUT the subnet ids:
output "public_subnets_id" {
value = "${join(",", aws_subnet.public.*.id)}"
}
here the example output of this:
public_subnets_id = subnet-84aae6f4,subnet-a12124e8
Here is my my code, where I am trying to split it and create the instance inside each subnet but can only create to the first subnet.
subnet_id = "${element(split(",", var.subnet_id), count.index)}"
public_subnets_id
andvar.subnet_id
– BMW