Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3_bucket - do not use the default region as location constraint (ceph) #2457

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- 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).
6 changes: 6 additions & 0 deletions plugins/module_utils/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,9 @@ def _list_objects_v2(client, **params):
def list_bucket_object_keys(client, bucket, prefix=None, max_keys=None, start_after=None):
response = _list_objects_v2(client, Bucket=bucket, Prefix=prefix, StartAfter=start_after, MaxKeys=max_keys)
return [c["Key"] for c in response.get("Contents", [])]


def get_s3_bucket_location(module):
if module.params.get("ceph") is True:
return module.params.get("region")
return module.region or "us-east-1"
5 changes: 2 additions & 3 deletions plugins/modules/s3_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.s3 import get_s3_bucket_location
from ansible_collections.amazon.aws.plugins.module_utils.s3 import list_bucket_inventory_configurations
from ansible_collections.amazon.aws.plugins.module_utils.s3 import s3_extra_params
from ansible_collections.amazon.aws.plugins.module_utils.s3 import validate_bucket_name
Expand Down Expand Up @@ -1232,9 +1233,7 @@ def create_or_update_bucket(s3_client, module: AnsibleAWSModule):
"""
name = module.params.get("name")
object_lock_enabled = module.params.get("object_lock_enabled")
# default to US Standard region,
# note: module.region will also try to pull a default out of the boto3 configs.
location = module.region or "us-east-1"
location = get_s3_bucket_location(module)

changed = False
result = {}
Expand Down
Loading