cherry-pick e59742eccd and resolve conflicts

[aws] Remove walrus conditional in aws_s3 module when using custom s3_url

fix aws_s3 module to use custum s3_url
pull/41306/head
Christian Groschupp 8 years ago committed by Matt Clay
parent c168cd482c
commit 34f08b4eb5

@ -0,0 +1,3 @@
---
bugfixes:
- allow custom endpoints to be used in the aws_s3 module (https://github.com/ansible/ansible/pull/36832)

@ -573,17 +573,6 @@ def is_fakes3(s3_url):
return False
def is_walrus(s3_url):
""" Return True if it's Walrus endpoint, not S3
We assume anything other than *.amazonaws.com is Walrus"""
if s3_url is not None:
o = urlparse(s3_url)
return not o.netloc.endswith('amazonaws.com')
else:
return False
def get_s3_connection(module, aws_connect_kwargs, location, rgw, s3_url):
if s3_url and rgw: # TODO - test this
rgw = urlparse(s3_url)
@ -602,9 +591,6 @@ def get_s3_connection(module, aws_connect_kwargs, location, rgw, s3_url):
params = dict(module=module, conn_type='client', resource='s3', region=location,
endpoint="%s://%s:%s" % (protocol, fakes3.hostname, to_text(port)),
use_ssl=fakes3.scheme == 'fakes3s', **aws_connect_kwargs)
elif is_walrus(s3_url):
walrus = urlparse(s3_url).hostname
params = dict(module=module, conn_type='client', resource='s3', region=location, endpoint=walrus, **aws_connect_kwargs)
else:
params = dict(module=module, conn_type='client', resource='s3', region=location, endpoint=s3_url, **aws_connect_kwargs)
return boto3_conn(**params)

Loading…
Cancel
Save