Last active
January 26, 2016 07:23
-
-
Save AlecTaylor/ef0e51f8b2aa13d987db to your computer and use it in GitHub Desktop.
This file contains 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 urllib2 | |
def get_ubuntu_ami(region='ap-southeast-2', arch='64-bit', root_store='ebs', codename='trusty', version='current'): | |
# Just a quick hack! | |
s = urllib2.urlopen( | |
'http://cloud-images.ubuntu.com/{codename}/{version}/'.format(codename=codename, version=version) | |
).read().replace(' ', '') | |
find = '''<tr> | |
<td><p>{region}</p></td> | |
<td><p>{arch}</p></td> | |
<td><p>{root_store}</p></td> | |
<td><p><buttontype="button"onClick="parent.location='https://console.aws.amazon.com/ec2/home?region={region}#launchAmi= | |
'''.format(region=region, arch=arch, root_store=root_store).rstrip() | |
return (lambda first: s[first + len(find):s.find("'", first + len(find))])(s.find(find)) | |
if __name__ == '__main__': | |
print latest_ubuntu_ami_hack() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment