What Does Region None Mean When Creating A Aws S3 Bucket?
I have just created a bucket with AWS CLI: aws s3 mb s3://new-bucket-created And then when listing all buckets in my S3 account with boto3: s3 = boto3.client('s3') response = s3.l
Solution 1:
Buckets in Region us-east-1 have a LocationConstraint of null .
To fix this, update your code
bucket_region = s3.get_bucket_location(Bucket=bucket_name).get('LocationConstraint', 'us-east-1')
(this assumes LocationConstraint
key doesn't actually exist in the response)
Or buckets.update({bucket_name: bucket_region or 'us-east-1'})
, which will return the region if defined, else fallsthrough to the default value
Post a Comment for "What Does Region None Mean When Creating A Aws S3 Bucket?"