Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Last active August 29, 2015 14:16
Show Gist options
  • Save gene1wood/01d745dc2c60433341de to your computer and use it in GitHub Desktop.
Save gene1wood/01d745dc2c60433341de to your computer and use it in GitHub Desktop.
#!/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