Skip to content

Commit 9a6e361

Browse files
committed
s3_bucket - do not use default region as location constraint when creating bucket on ceph cluster
1 parent c185dc3 commit 9a6e361

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
bugfixes:
3+
- s3_bucket - Do not use default region as location constraint when creating bucket on ceph cluster (https://github.com/ansible-collections/amazon.aws/issues/2420).

plugins/module_utils/s3.py

+6
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,9 @@ def _list_objects_v2(client, **params):
198198
def list_bucket_object_keys(client, bucket, prefix=None, max_keys=None, start_after=None):
199199
response = _list_objects_v2(client, Bucket=bucket, Prefix=prefix, StartAfter=start_after, MaxKeys=max_keys)
200200
return [c["Key"] for c in response.get("Contents", [])]
201+
202+
203+
def get_s3_bucket_location(module):
204+
if module.params.get("ceph") is True:
205+
return module.params.get("region")
206+
return module.region or "us-east-1"

plugins/modules/s3_bucket.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@
563563
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
564564
from ansible_collections.amazon.aws.plugins.module_utils.s3 import list_bucket_inventory_configurations
565565
from ansible_collections.amazon.aws.plugins.module_utils.s3 import s3_extra_params
566-
from ansible_collections.amazon.aws.plugins.module_utils.s3 import validate_bucket_name
566+
from ansible_collections.amazon.aws.plugins.module_utils.s3 import validate_bucket_name, get_s3_bucket_location
567567
from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list
568568
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
569569

@@ -1232,9 +1232,7 @@ def create_or_update_bucket(s3_client, module: AnsibleAWSModule):
12321232
"""
12331233
name = module.params.get("name")
12341234
object_lock_enabled = module.params.get("object_lock_enabled")
1235-
# default to US Standard region,
1236-
# note: module.region will also try to pull a default out of the boto3 configs.
1237-
location = module.region or "us-east-1"
1235+
location = get_s3_bucket_location(module)
12381236

12391237
changed = False
12401238
result = {}

0 commit comments

Comments
 (0)