s3_bucket: don't assume anything other than *.amazonaws.com is Walrus (#46745)

For example, 'https://s3.nl-ams.scw.cloud' isn't Walrus.
When Walrus is used, 's3_url' should be a hostname.
pull/47940/head
Pilou 6 years ago committed by ansibot
parent d14f9dc685
commit cfe7c9606c

@ -0,0 +1,3 @@
---
minor_changes:
- "s3_bucket - Walrus users: ``s3_url`` must be a FQDN without scheme not path."

@ -43,7 +43,9 @@ options:
- The JSON policy as a string.
s3_url:
description:
- S3 URL endpoint for usage with Ceph, Eucalyptus and fakes3 etc. Otherwise assumes AWS.
- S3 URL endpoint for usage with Ceph, Eucalyptus and fakes3 etc.
- Assumes AWS if not specified.
- For Walrus, use FQDN of the endpoint without scheme nor path.
aliases: [ S3_URL ]
ceph:
description:
@ -508,17 +510,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.hostname.endswith('amazonaws.com')
else:
return False
def get_s3_client(module, aws_connect_kwargs, location, ceph, s3_url):
if s3_url and ceph: # TODO - test this
ceph = urlparse(s3_url)
@ -537,9 +528,6 @@ def get_s3_client(module, aws_connect_kwargs, location, ceph, 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