From 2b2285eb675b94d452eb3a1416ef7e8ada3ac1bc Mon Sep 17 00:00:00 2001 From: Etherdaemon Date: Tue, 20 Oct 2015 16:38:27 +1000 Subject: [PATCH 1/2] fixes #12831 by updating the boto iam connection method to connect_to_region --- cloud/amazon/iam.py | 2 +- cloud/amazon/iam_cert.py | 3 ++- cloud/amazon/iam_policy.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cloud/amazon/iam.py b/cloud/amazon/iam.py index 8864cb10a6f..2d4b908e80e 100644 --- a/cloud/amazon/iam.py +++ b/cloud/amazon/iam.py @@ -565,7 +565,7 @@ def main(): region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) try: - iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs) + iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) except boto.exception.NoAuthHandlerFound, e: module.fail_json(msg=str(e)) diff --git a/cloud/amazon/iam_cert.py b/cloud/amazon/iam_cert.py index 0c36abef322..2c36f921212 100644 --- a/cloud/amazon/iam_cert.py +++ b/cloud/amazon/iam_cert.py @@ -107,6 +107,7 @@ import sys try: import boto import boto.iam + import boto.ec2 HAS_BOTO = True except ImportError: HAS_BOTO = False @@ -246,7 +247,7 @@ def main(): region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) try: - iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs) + iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) except boto.exception.NoAuthHandlerFound, e: module.fail_json(msg=str(e)) diff --git a/cloud/amazon/iam_policy.py b/cloud/amazon/iam_policy.py index 0d2ed506457..b5242577ff4 100644 --- a/cloud/amazon/iam_policy.py +++ b/cloud/amazon/iam_policy.py @@ -307,7 +307,7 @@ def main(): region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) try: - iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs) + iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) except boto.exception.NoAuthHandlerFound, e: module.fail_json(msg=str(e)) From 08559670e5f2d8104cc94de3914ec039883766a5 Mon Sep 17 00:00:00 2001 From: Etherdaemon Date: Thu, 22 Oct 2015 09:12:58 +1000 Subject: [PATCH 2/2] Update try statement as pointed out by defionscode --- cloud/amazon/iam.py | 5 ++++- cloud/amazon/iam_cert.py | 5 ++++- cloud/amazon/iam_policy.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cloud/amazon/iam.py b/cloud/amazon/iam.py index 2d4b908e80e..c1cd79f9a3f 100644 --- a/cloud/amazon/iam.py +++ b/cloud/amazon/iam.py @@ -565,7 +565,10 @@ def main(): region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) try: - iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) + if region: + iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) + else: + iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs) except boto.exception.NoAuthHandlerFound, e: module.fail_json(msg=str(e)) diff --git a/cloud/amazon/iam_cert.py b/cloud/amazon/iam_cert.py index 2c36f921212..cc79d1cdc1c 100644 --- a/cloud/amazon/iam_cert.py +++ b/cloud/amazon/iam_cert.py @@ -247,7 +247,10 @@ def main(): region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) try: - iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) + if region: + iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) + else: + iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs) except boto.exception.NoAuthHandlerFound, e: module.fail_json(msg=str(e)) diff --git a/cloud/amazon/iam_policy.py b/cloud/amazon/iam_policy.py index b5242577ff4..c17e1278ddc 100644 --- a/cloud/amazon/iam_policy.py +++ b/cloud/amazon/iam_policy.py @@ -307,7 +307,10 @@ def main(): region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) try: - iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) + if region: + iam = boto.iam.connect_to_region(region, **aws_connect_kwargs) + else: + iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs) except boto.exception.NoAuthHandlerFound, e: module.fail_json(msg=str(e))