diff --git a/cloud/ec2_elb b/cloud/ec2_elb index 0437fd29e1d..ca776c4edf9 100644 --- a/cloud/ec2_elb +++ b/cloud/ec2_elb @@ -53,11 +53,6 @@ options: - AWS Access API key required: false default: None - elb_region: - description: - - AWS Region the load balancer is in - required: false - default: None """ @@ -88,7 +83,6 @@ import os try: import boto - from boto.ec2.elb import regions as elb_regions except ImportError: print "failed=True msg='boto required for this module'" sys.exit(1) @@ -98,23 +92,12 @@ class ElbManager: """Handles EC2 instance ELB registration and de-registration""" def __init__(self, module, instance_id=None, ec2_elbs=None, - ec2_access_key=None, ec2_secret_key=None, elb_region_name=None): + ec2_access_key=None, ec2_secret_key=None): self.ec2_access_key = ec2_access_key self.ec2_secret_key = ec2_secret_key self.module = module self.instance_id = instance_id - self.elb_region = None - - if elb_region_name is not None: - for region in elb_regions(): - if region.name == elb_region_name: - self.elb_region = region - - if self.elb_region is None: - self.module.fail_json(msg=str("Invalid region")) - self.lbs = self._get_instance_lbs(ec2_elbs) - # if there are no ELBs to operate on # there will be no changes made if len(self.lbs) > 0: @@ -157,7 +140,7 @@ class ElbManager: are attached to self.instance_id""" try: - elb = boto.connect_elb(self.ec2_access_key, self.ec2_secret_key, region=self.elb_region) + elb = boto.connect_elb(self.ec2_access_key, self.ec2_secret_key) except boto.exception.NoAuthHandlerFound, e: self.module.fail_json(msg=str(e)) elbs = elb.get_all_load_balancers() @@ -182,15 +165,13 @@ def main(): instance_id={'required': True}, ec2_elbs={'default': None, 'required': False}, ec2_secret_key={'default': None, 'aliases': ['EC2_SECRET_KEY']}, - ec2_access_key={'default': None, 'aliases': ['EC2_ACCESS_KEY']}, - elb_region={'required': False, 'default': None} + ec2_access_key={'default': None, 'aliases': ['EC2_ACCESS_KEY']} ) ) ec2_secret_key = module.params['ec2_secret_key'] ec2_access_key = module.params['ec2_access_key'] ec2_elbs = module.params['ec2_elbs'] - elb_region = module.params['elb_region'] if module.params['state'] == 'present' and 'ec2_elbs' not in module.params: module.fail_json(msg="ELBs are required for registration") @@ -202,7 +183,7 @@ def main(): instance_id = module.params['instance_id'] elb_man = ElbManager(module, instance_id, ec2_elbs, ec2_access_key, - ec2_secret_key, elb_region) + ec2_secret_key) if module.params['state'] == 'present': elb_man.register()