Last active
August 29, 2015 14:16
-
-
Save gene1wood/01d745dc2c60433341de 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/python | |
import argparse, sys, re, time | |
from boto.vpc import connect_to_region | |
import boto.exception | |
import boto | |
import boto.ec2 | |
#---------------------------------------------------------- | |
def create_connection_to_aws(region): | |
#---------------------------------------------------------- | |
"""this subroutine creates a connection to the appropriate region and | |
returns a handle to the connection""" | |
print "attempting to connect to AWS...", | |
try: | |
connection = boto.connect_vpc(region=boto.ec2.get_region(region), profile_name='sandbox') | |
except Exception, e: | |
print "connection failed." | |
print e | |
sys.exit(1) | |
print "connected." | |
return connection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment