I’m new to terraform, I’m creating a swarm cluster (3 managers, 5+ workers) to run 30+ wordpress sites. As the instances IP addresses can change on instance restart, swarm nodes would loose connectivity to the cluster because of the new IP address and they would need to re-join the cluster.
So to avoid this problem I want to assign elastic IP’s to all the instances when they are created by terraform. It’s easy to assign an elastic IP to an instance using the aws_eip resource if you have the instance id at hand, but how to do it for multiple instances created using a single aws_instance resource with count parameter > 1.
How can I get the ids of those newly created instances so I can loop over them and create an elastic ip address associated to each of them ?
Thanks and merry christmas !