1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Patch to remove dependency on boto when only using boto3

Updated with explicit check for HAS_BOTO3
This commit is contained in:
Jonathan Davila 2015-11-13 18:19:09 -07:00
parent 300ee227a2
commit 1b76a9cef2

View file

@ -29,6 +29,7 @@ import os
try:
import boto3
import botocore
HAS_BOTO3 = True
except:
HAS_BOTO3 = False
@ -129,10 +130,14 @@ def get_aws_connection_info(module, boto3=False):
elif 'EC2_REGION' in os.environ:
region = os.environ['EC2_REGION']
else:
# boto.config.get returns None if config not found
region = boto.config.get('Boto', 'aws_region')
if not region:
region = boto.config.get('Boto', 'ec2_region')
if not boto3:
# boto.config.get returns None if config not found
region = boto.config.get('Boto', 'aws_region')
if not region:
region = boto.config.get('Boto', 'ec2_region')
elif boto3 and HAS_BOTO3:
# here we don't need to make an additional call, will default to 'us-east-1' if the below evaluates to None.
region = botocore.session.get_session().get_config_variable('region')
if not security_token:
if 'AWS_SECURITY_TOKEN' in os.environ: