Last active
December 30, 2015 02:09
-
-
Save cjhanks/7760337 to your computer and use it in GitHub Desktop.
Ec2Ls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
from sys import argv | |
from fnmatch import fnmatch | |
from boto.ec2 import connect_to_region | |
pattern = '*' if 1 is len(argv) else argv[1] | |
machines = [] | |
for r in connect_to_region('us-east-1').get_all_instances(): | |
for i in r.instances: | |
name = i.tags['Name'] if 'Name' in i.tags else '' | |
if fnmatch(name, pattern): | |
machines.append((name, i)) | |
machines = sorted(machines, key = lambda x: x[0]) | |
for m in machines: | |
print('-' * 80) | |
print( | |
'''{name:<48} {inst.launch_time} | |
{inst.public_dns_name} | |
{inst.private_dns_name}'''.format(name = m[0], inst = m[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment