@ -31,6 +31,7 @@ __metaclass__ = type
import os
import os
import re
import re
import sys
import traceback
import traceback
from ansible . module_utils . ansible_release import __version__
from ansible . module_utils . ansible_release import __version__
@ -136,13 +137,15 @@ def _boto3_conn(conn_type=None, resource=None, region=None, endpoint=None, **par
' the conn_type parameter in the boto3_conn function '
' the conn_type parameter in the boto3_conn function '
' call ' )
' call ' )
if params . get ( ' config ' ) :
config = botocore . config . Config (
config = params . pop ( ' config ' )
user_agent_extra = ' Ansible/ {0} ' . format ( __version__ ) ,
config . user_agent_extra = ' Ansible/ {0} ' . format ( __version__ )
)
else :
config = botocore . config . Config (
if params . get ( ' config ' ) is not None :
user_agent_extra = ' Ansible/ {0} ' . format ( __version__ ) ,
config = config . merge ( params . pop ( ' config ' ) )
)
if params . get ( ' aws_config ' ) is not None :
config = config . merge ( params . pop ( ' aws_config ' ) )
session = boto3 . session . Session (
session = boto3 . session . Session (
profile_name = profile ,
profile_name = profile ,
)
)
@ -186,6 +189,7 @@ def aws_common_argument_spec():
validate_certs = dict ( default = True , type = ' bool ' ) ,
validate_certs = dict ( default = True , type = ' bool ' ) ,
security_token = dict ( aliases = [ ' access_token ' ] , no_log = True ) ,
security_token = dict ( aliases = [ ' access_token ' ] , no_log = True ) ,
profile = dict ( ) ,
profile = dict ( ) ,
aws_config = dict ( type = ' dict ' ) ,
)
)
@ -211,6 +215,7 @@ def get_aws_connection_info(module, boto3=False):
region = module . params . get ( ' region ' )
region = module . params . get ( ' region ' )
profile_name = module . params . get ( ' profile ' )
profile_name = module . params . get ( ' profile ' )
validate_certs = module . params . get ( ' validate_certs ' )
validate_certs = module . params . get ( ' validate_certs ' )
config = module . params . get ( ' aws_config ' )
if not ec2_url :
if not ec2_url :
if ' AWS_URL ' in os . environ :
if ' AWS_URL ' in os . environ :
@ -309,6 +314,13 @@ def get_aws_connection_info(module, boto3=False):
boto_params [ ' validate_certs ' ] = validate_certs
boto_params [ ' validate_certs ' ] = validate_certs
if config is not None :
if HAS_BOTO3 and boto3 :
boto_params [ ' aws_config ' ] = botocore . config . Config ( * * config )
elif HAS_BOTO and not boto3 :
if ' user_agent ' in config :
sys . modules [ " boto.connection " ] . UserAgent = config [ ' user_agent ' ]
for param , value in boto_params . items ( ) :
for param , value in boto_params . items ( ) :
if isinstance ( value , binary_type ) :
if isinstance ( value , binary_type ) :
boto_params [ param ] = text_type ( value , ' utf-8 ' , ' strict ' )
boto_params [ param ] = text_type ( value , ' utf-8 ' , ' strict ' )