Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get public IP addresses of all nodes in an Amazon EC2 cluster? [closed]

Setup:

I am able to spin-off an Amazon EC2 cluster with 5 nodes. Now I have to install some package on it. I have written a script which takes list of IP addresses and installs that package on those machines. The script to install the package is ready and working.

Problem:

Right now I am creating the list of IP address manually, like going to the Amazon Management Console and click on each node and get the Public DNS Name/IP (duh!). I would like to automate this part as soon I will need to spin-off clusters of few hundred nodes and manually retrieving 100s IP address is painful.

So in short, is there a way by which I can get public IP address of all the nodes in my cluster? Some command-line script would be ideal I guess.

like image 717
Bhushan Avatar asked Mar 19 '14 19:03

Bhushan


People also ask

How can software determine the public and private IP addresses of the Amazon EC2?

How can software determine the public and private IP addresses of the Amazon EC2 instance that it is running on? Query the appropriate Amazon CloudWatch metric. Use ipconfig or ifconfig command. Query the local instance userdata.


1 Answers

You should probably use AWS CLI:

aws ec2 describe-instances --query "Reservations[*].Instances[*].PublicIpAddress" --output text

This should give you a list of public IPs.

like image 153
Uri Agassi Avatar answered Sep 17 '22 18:09

Uri Agassi