Skip to content

Instantly share code, notes, and snippets.

@lfrancois
Created July 22, 2015 02:01
Show Gist options
  • Save lfrancois/97b883fad0016709ee92 to your computer and use it in GitHub Desktop.
Save lfrancois/97b883fad0016709ee92 to your computer and use it in GitHub Desktop.
get the hostname tag from aws and assign it to jumpcloud tag
#! /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