Skip to content

Instantly share code, notes, and snippets.

@bcicen
Created July 6, 2015 20:51
Show Gist options
  • Save bcicen/55818b42116e6674bf47 to your computer and use it in GitHub Desktop.
Save bcicen/55818b42116e6674bf47 to your computer and use it in GitHub Desktop.
#!/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