Skip to content

Instantly share code, notes, and snippets.

@adammck
Created January 12, 2015 21:19
Show Gist options
  • Save adammck/b2eab1c0eda055ed3948 to your computer and use it in GitHub Desktop.
Save adammck/b2eab1c0eda055ed3948 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import re
import sys
import urllib2
from datetime import datetime
print "# Generated by %s at %s" % (sys.argv[0], datetime.now())
print
USER_DATA_URL = "http://169.254.169.254/latest/user-data"
res = urllib2.urlopen(USER_DATA_URL)
for line in res.readlines():
key, val = re.split(r'\s*=\s*', line.strip(), 1)
print 'export %s="%s"' % (key.upper(), val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment