Skip to content

Instantly share code, notes, and snippets.

@ddub
Last active January 19, 2016 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddub/9225d01d544fca9f5f0c to your computer and use it in GitHub Desktop.
Save ddub/9225d01d544fca9f5f0c to your computer and use it in GitHub Desktop.
show-ips-for-asg

To use;

docker run --rm -it ddub/show-ips-for-asg 'autoscale_group_name'

FROM python:3-onbuild
RUN chmod 755 *.py
ENTRYPOINT [ "/usr/src/app/show-ips-for-asg.py" ]
#!/usr/local/bin/python
import boto.ec2
import sys
import os
conn = boto.ec2.connect_to_region(
os.getenv('AWS_DEFAULT_REGION', 'us-east-1')
)
reservations = conn.get_all_instances(
filters={"tag:aws:autoscaling:groupName": sys.argv[1]}
)
print (' '.join([i.private_ip_address
for r in reservations
for i in r.instances
if i.state == 'running']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment