From 59e499f8f00e4068b68c147b8f3002535ad706e0 Mon Sep 17 00:00:00 2001 From: "Ryan S. Brown" Date: Wed, 6 Jul 2016 10:38:18 -0400 Subject: [PATCH] Respect profiles & credentials for boto3 inventory Using boto3 directly wasn't properly using profiles set in the `ec2.ini` file, this change uses the `module_utils` boto3_conn instead. --- contrib/inventory/ec2.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/inventory/ec2.py b/contrib/inventory/ec2.py index f2622ef6f14..a870b8fcfed 100755 --- a/contrib/inventory/ec2.py +++ b/contrib/inventory/ec2.py @@ -131,6 +131,8 @@ from boto import elasticache from boto import route53 import six +from ansible.module_utils import ec2 as ec2_utils + HAS_BOTO3 = False try: import boto3 @@ -591,9 +593,10 @@ class Ec2Inventory(object): def include_rds_clusters_by_region(self, region): if not HAS_BOTO3: - module.fail_json(message="This module requires boto3 be installed - please install boto3 and try again") - - client = self.connect_to_aws(rds, region) + self.fail_with_error("Working with RDS clusters requires boto3 - please install boto3 and try again", + "getting RDS clusters") + + client = ec2_utils.boto3_inventory_conn('client', 'rds', region, **self.credentials) clusters = client.describe_db_clusters()["DBClusters"] account_id = boto.connect_iam().get_user().arn.split(':')[4] c_dict = {}