Skip to content

Commit

Permalink
fix(storage): avoid edge case with us-east-1
Browse files Browse the repository at this point in the history
  • Loading branch information
frgfm committed Jan 15, 2025
1 parent eda8110 commit 041c86f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/services/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,14 @@ def __init__(
def create_bucket(self, bucket_name: str) -> bool:
"""Create a new bucket in S3 storage"""
try:
self._s3.create_bucket(
Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": self._s3.meta.region_name}
# https://stackoverflow.com/questions/51912072/invalidlocationconstraint-error-while-creating-s3-bucket-when-the-used-command-i
# https://github.com/localstack/localstack/issues/8000
config_ = (
{}
if self._s3.meta.region_name == "us-east-1"
else {"CreateBucketConfiguration": {"LocationConstraint": self._s3.meta.region_name}}
)
self._s3.create_bucket(Bucket=bucket_name, **config_)
return True
except ClientError as e:
logger.warning(e)
Expand Down

0 comments on commit 041c86f

Please sign in to comment.