From 543cb13f424bd67715b89cc0154b4e7dfd19422d Mon Sep 17 00:00:00 2001 From: Michael Weinrich Date: Sun, 21 Jun 2015 23:51:14 +0200 Subject: [PATCH] Fix connection creation to allow usage of profiles with boto --- lib/ansible/modules/cloud/amazon/iam_policy.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/iam_policy.py b/lib/ansible/modules/cloud/amazon/iam_policy.py index d5f56eca209..5026169e104 100644 --- a/lib/ansible/modules/cloud/amazon/iam_policy.py +++ b/lib/ansible/modules/cloud/amazon/iam_policy.py @@ -133,6 +133,7 @@ import urllib try: import boto import boto.iam + import boto.ec2 HAS_BOTO = True except ImportError: HAS_BOTO = False @@ -321,13 +322,10 @@ def main(): else: pdoc=None - ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module) + region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module) try: - iam = boto.iam.connection.IAMConnection( - aws_access_key_id=aws_access_key, - aws_secret_access_key=aws_secret_key, - ) + iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs) except boto.exception.NoAuthHandlerFound, e: module.fail_json(msg=str(e))