Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python2.7
import os
import sys
from boto import route53
def fail():
print('Both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables must be defined')
sys.exit(1)
if __name__ == '__main__':
aws_id = os.environ.get('AWS_ACCESS_KEY_ID')
aws_secret = os.environ.get('AWS_SECRET_ACCESS_KEY')
if not aws_id or not aws_secret:
fail()
a_records = []
r53 = route53.Route53Connection()
for zone in r53.get_zones():
[ a_records.append(r.name) for r in zone.get_records() if r.type == 'A' ]
home = os.path.expanduser("~")
with open('' + home + '/.bash_profile', 'a') as of:
of.write('complete -W "%s" ssh\n' % (' '.join(a_records)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment