Skip to content

Commit

Permalink
InvalidLocationConstraint error in AWS S3 handled. (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
GEizaguirre authored Nov 12, 2024
1 parent b95477a commit fdb6432
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lithops/storage/backends/aws_s3/aws_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ def create_bucket(self, bucket_name):
logger.debug(f"Could not find the bucket {bucket_name} in the AWS S3 storage backend")
logger.debug(f"Creating new bucket {bucket_name} in the AWS S3 storage backend")
bucket_config = {'LocationConstraint': self.region}
self.s3_client.create_bucket(Bucket=bucket_name, CreateBucketConfiguration=bucket_config)
try:
self.s3_client.create_bucket(Bucket=bucket_name, CreateBucketConfiguration=bucket_config)
except botocore.exceptions.ClientError as ce:
error_code = ce.response.get('Error', {}).get('Code', 'Unknown')
if error_code == "InvalidLocationConstraint" and self.region == "us-east-1":
self.s3_client.create_bucket(Bucket=bucket_name)
else:
raise ce
else:
raise e

Expand Down

0 comments on commit fdb6432

Please sign in to comment.