Skip to content

Commit

Permalink
s3_bucket - fix MethodNotAllowed in regions that don't support transf…
Browse files Browse the repository at this point in the history
…er acceleration

fixes: ansible-collections#2266
  • Loading branch information
tremble committed Aug 29, 2024
1 parent 0bca4b9 commit c7d4eda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/2266-acceleration-eu_north_1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- s3_bucket - fixes ``MethodNotAllowed`` exceptions caused by fetching transfer acceleration state in regions that don't support it (https://github.com/ansible-collections/amazon.aws/issues/2266).
8 changes: 5 additions & 3 deletions plugins/modules/s3_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,11 @@ def handle_bucket_accelerate(s3_client, module: AnsibleAWSModule, name: str) ->
except is_boto3_error_code(["NotImplemented", "XNotImplemented"]) as e:
if accelerate_enabled is not None:
module.fail_json_aws(e, msg="Fetching bucket transfer acceleration state is not supported")
except is_boto3_error_code("UnsupportedArgument") as e: # pylint: disable=duplicate-except
# -- Transfer Acceleration is not available in AWS GovCloud (US).
# -- https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-s3.html#govcloud-S3-diffs
except is_boto3_error_code(["UnsupportedArgument", "MethodNotAllowed"]) as e: # pylint: disable=duplicate-except
# - Transfer Acceleration is not available in AWS GovCloud (US) and throws UnsupportedArgument.
# https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-s3.html#govcloud-S3-diffs
# - Transfer Acceleration is not available in some AWS regions and throws MethodNotAllowed
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration.html
module.warn("Tranfer acceleration is not available in S3 bucket region.")
accelerate_enabled_result = False
except is_boto3_error_code("AccessDenied") as e: # pylint: disable=duplicate-except
Expand Down

0 comments on commit c7d4eda

Please sign in to comment.