diff --git a/changelogs/fragments/aws_s3_fix_custom_endpoints.yaml b/changelogs/fragments/aws_s3_fix_custom_endpoints.yaml new file mode 100644 index 00000000000..cf20f2e7273 --- /dev/null +++ b/changelogs/fragments/aws_s3_fix_custom_endpoints.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: +- allow custom endpoints to be used in the aws_s3 module (https://github.com/ansible/ansible/pull/36832) diff --git a/lib/ansible/modules/cloud/amazon/aws_s3.py b/lib/ansible/modules/cloud/amazon/aws_s3.py index 949c3c9e4e4..33b94d64907 100644 --- a/lib/ansible/modules/cloud/amazon/aws_s3.py +++ b/lib/ansible/modules/cloud/amazon/aws_s3.py @@ -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)