Please check following scenario:
I want to make a cluster of 3 instances, so the 3 instances need to know the private IP addresses of each other.
What is the best way to get the IP addresses of other 2 instances in 3rd instance? Shall I keep a small script inside the AMI which will throw the IP address outside?
In cloudformation, you can make use of the GetAtt intrinsic function, which returns the value of an attribute from a resource in the template.
To get the PrivateIp, it would look like this:
{ "Fn::GetAtt" : [ "Ec2Instance", "PrivateIp" ] }