forked from nccgroup/opinel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_ec2.py
35 lines (28 loc) · 893 Bytes
/
utils_ec2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python2
# Import AWS utils
from AWSUtils.utils import *
# Import third-party packages
import boto
from boto import ec2
from boto.ec2 import elb
########################################
##### Helpers
########################################
#
# Connect to EC2 API
#
def connect_ec2(key_id, secret, session_token, region_name):
try:
return boto.ec2.connect_to_region(region_name, aws_access_key_id = key_id, aws_secret_access_key = secret, security_token = session_token)
except Exception, e:
printException(e)
return None
#
# Connect to ELB API
#
def connect_elb(key_id, secret, session_token, region_name):
try:
return boto.ec2.elb.connect_to_region(region_name, aws_access_key_id = key_id, aws_secret_access_key = secret, security_token = session_token)
except Exception, e:
printException(e)
return None