Skip to content

Commit 5188f77

Browse files
committed
fix(create_bucket): avoid S3 InvalidLocationConstraint error
calling create_bucket(bucket_name, region="us-east-1") yields the following error: boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request <?xml version="1.0" encoding="UTF-8"?> <Error><Code>InvalidLocationConstraint</Code> <Message>The specified location-constraint is not valid</Message> <LocationConstraint>us-east-1</LocationConstraint>...</Error> based on the comments in boto/boto3#125 this commit omits the region kwarg to the create_bucket() call when `s3.region` is set to "us-east-1"
1 parent 6659712 commit 5188f77

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rootfs/bin/create_bucket

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ if os.getenv('DATABASE_STORAGE') == "s3":
2626
conn = boto.s3.connect_to_region(region)
2727
if not bucket_exists(conn, bucket_name):
2828
try:
29-
conn.create_bucket(bucket_name, location=region)
29+
if region == "us-east-1":
30+
# use "US Standard" region. workaround for https://github.com/boto/boto3/issues/125
31+
conn.create_bucket(bucket_name)
32+
else:
33+
conn.create_bucket(bucket_name, location=region)
3034
# NOTE(bacongobbler): for versions prior to v2.9.0, the bucket is created in the default region.
3135
# if we got here, we need to propagate "us-east-1" into WALE_S3_ENDPOINT because the bucket
3236
# exists in a different region and we cannot find it.

0 commit comments

Comments
 (0)