Created
February 9, 2016 21:50
-
-
Save greinacker/3888373ee4a5cb54732c to your computer and use it in GitHub Desktop.
Revisions
-
greinacker created this gist
Feb 9, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ # coding: utf-8 import sys; sys.path.append('../boto-module') import boto.ec2 import time import keychain import clipboard import console import webbrowser instance_id = "i-123456ab" key = "ABCDEFGHIJKLMNOPQRST" return_url = None if len(sys.argv) >= 2: return_url = sys.argv[1] secret = keychain.get_password("aws", key) if secret == None: secret = console.password_alert("Enter secret key") keychain.set_password("aws",key,secret) print "Connecting" ec2_conn = boto.connect_ec2(aws_access_key_id=key,aws_secret_access_key=secret) print "Starting instance" instances = ec2_conn.start_instances(instance_ids=[instance_id]) instance = instances[0] print "Waiting for IP" ip_address = None waiting = True while waiting: status = instance.update() print status ip_address = instance.ip_address if ip_address != None: waiting = False time.sleep(2) print "Public IP: {}".format(ip_address) clipboard.set(ip_address) print "IP address {} copied to clipboard".format(ip_address) if return_url != None: webbrowser.open(return_url) This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ # coding: utf-8 import sys; sys.path.append('../boto-module') import boto.ec2 import time import keychain import clipboard import console import webbrowser instance_id = "i-123456ab" key = "ABCDEFGHIJKLMNOPQRST" return_url = None if len(sys.argv) >= 2: return_url = sys.argv[1] secret = keychain.get_password("aws", key) if secret == None: secret = console.password_alert("Enter secret key") keychain.set_password("aws",key,secret) print "Connecting" ec2_conn = boto.connect_ec2(aws_access_key_id=key,aws_secret_access_key=secret) print "Stopping instance" ec2_conn.stop_instances(instance_ids=[instance_id]) msg = "Shutdown in progress" clipboard.set(msg) print msg if return_url != None: webbrowser.open(return_url)