Skip to content

Commit 6bbf22f

Browse files
authored
s3_bucket - do not use default region as location constraint when creating bucket on ceph cluster (#2457)
SUMMARY Closes #2420 Do not use the default region as a location constraint when creating a bucket. ISSUE TYPE Bugfix Pull Request COMPONENT NAME s3_bucket Reviewed-by: Mark Chappell Reviewed-by: Alina Buzachis
1 parent 429cff0 commit 6bbf22f

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
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-3
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@
561561
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule
562562
from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies
563563
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
564+
from ansible_collections.amazon.aws.plugins.module_utils.s3 import get_s3_bucket_location
564565
from ansible_collections.amazon.aws.plugins.module_utils.s3 import list_bucket_inventory_configurations
565566
from ansible_collections.amazon.aws.plugins.module_utils.s3 import s3_extra_params
566567
from ansible_collections.amazon.aws.plugins.module_utils.s3 import validate_bucket_name
@@ -1232,9 +1233,7 @@ def create_or_update_bucket(s3_client, module: AnsibleAWSModule):
12321233
"""
12331234
name = module.params.get("name")
12341235
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"
1236+
location = get_s3_bucket_location(module)
12381237

12391238
changed = False
12401239
result = {}

0 commit comments

Comments
 (0)