Created
July 22, 2015 02:01
-
-
Save lfrancois/97b883fad0016709ee92 to your computer and use it in GitHub Desktop.
get the hostname tag from aws and assign it to jumpcloud tag
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 python | |
import boto.ec2 | |
conn = boto.ec2.connect_to_region("us-east-1") | |
reservations = conn.get_all_instances() | |
for res in reservations: | |
for inst in res.instances: | |
if 'hostname' in inst.tags: | |
print "%s (%s) [%s]" % (inst.tags['hostname'], inst.id, inst.state) | |
else: | |
print "NO HOSTNAME TAG %s [%s]" % (inst.id, inst.state) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment