Commit e2e2df4c by Kevin Falcone

Connect specifically to a region

We now run this script places other than us-east-1 and we use the
box's IAM role rather than a profile.
parent 3513b8f3
...@@ -30,8 +30,10 @@ group and state. ...@@ -30,8 +30,10 @@ group and state.
""" """
import argparse import argparse
import boto import boto
import boto.ec2.autoscale
import json import json
from collections import defaultdict from collections import defaultdict
from os import environ
class LifecycleInventory(): class LifecycleInventory():
...@@ -54,7 +56,7 @@ class LifecycleInventory(): ...@@ -54,7 +56,7 @@ class LifecycleInventory():
return environment,deployment return environment,deployment
def get_instance_dict(self): def get_instance_dict(self):
ec2 = boto.connect_ec2(profile_name=self.profile) ec2 = boto.ec2.connect_to_region(region,profile_name=self.profile)
reservations = ec2.get_all_instances() reservations = ec2.get_all_instances()
dict = {} dict = {}
...@@ -65,8 +67,8 @@ class LifecycleInventory(): ...@@ -65,8 +67,8 @@ class LifecycleInventory():
return dict return dict
def run(self): def run(self):
autoscale = boto.connect_autoscale(profile_name=self.profile) asg = boto.ec2.autoscale.connect_to_region(region,profile_name=self.profile)
groups = autoscale.get_all_groups() groups = asg.get_all_groups()
instances = self.get_instance_dict() instances = self.get_instance_dict()
inventory = defaultdict(list) inventory = defaultdict(list)
...@@ -92,7 +94,6 @@ if __name__=="__main__": ...@@ -92,7 +94,6 @@ if __name__=="__main__":
parser.add_argument('-l', '--list', help='Ansible passes this, we ignore it.', action='store_true', default=True) parser.add_argument('-l', '--list', help='Ansible passes this, we ignore it.', action='store_true', default=True)
args = parser.parse_args() args = parser.parse_args()
LifecycleInventory(args.profile).run() region = environ.get('AWS_REGION','us-east-1')
LifecycleInventory(args.profile).run()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment