diff --git a/lib/ansible/modules/cloud/amazon/s3_bucket.py b/lib/ansible/modules/cloud/amazon/s3_bucket.py index d530d836b3..814a8a5eb4 100644 --- a/lib/ansible/modules/cloud/amazon/s3_bucket.py +++ b/lib/ansible/modules/cloud/amazon/s3_bucket.py @@ -393,6 +393,11 @@ def main(): flavour = 'aws' + # bucket names with .'s in them need to use the calling_format option, + # otherwise the connection will fail. See https://github.com/boto/boto/issues/2836 + # for more details. + aws_connect_params['calling_format'] = OrdinaryCallingFormat() + # Look at s3_url and tweak connection settings # if connecting to Walrus or fakes3 try: @@ -402,7 +407,6 @@ def main(): host=ceph.hostname, port=ceph.port, is_secure=ceph.scheme == 'https', - calling_format=OrdinaryCallingFormat(), **aws_connect_params ) flavour = 'ceph' @@ -412,14 +416,14 @@ def main(): is_secure=fakes3.scheme == 'fakes3s', host=fakes3.hostname, port=fakes3.port, - calling_format=OrdinaryCallingFormat(), **aws_connect_params ) elif is_walrus(s3_url): + del aws_connect_params['calling_format'] walrus = urlparse.urlparse(s3_url).hostname connection = boto.connect_walrus(walrus, **aws_connect_params) else: - connection = boto.s3.connect_to_region(location, is_secure=True, calling_format=OrdinaryCallingFormat(), **aws_connect_params) + connection = boto.s3.connect_to_region(location, is_secure=True, **aws_connect_params) # use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases if connection is None: connection = boto.connect_s3(**aws_connect_params)