Calling AWS for current nodes in a group instead of hardcoding public IPs
17 Mar 2017 - Aaron Dodd
When integrating CI/CD with cloud instances, the old-school method of specifying a server IP is problematic since a well-architected cloud solution allows for instance to be replaced as needed. Instead, Jenkins or other processes should verify the current running nodes before issuing a connection attempt.
Below is a sample query that return the public DNS names of servers tagged with a certain value (Group=fancyapp1).
The response would look like:
Or, if you just want the first node, change Reservations[*] to Reservations. And if you only want the public IP, remove the Name: part of the query and change output to –text:
In this case the output would be:
From the source script, you could just set the result of the above to a variable for the server to connect to.