Skip to content

Commit a885078

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 1ef4525 commit a885078

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

rootfs/bin/create-bucket

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ if os.getenv('REGISTRY_STORAGE') == "s3" and os.getenv('REGISTRY_STORAGE_S3_BACK
2525
conn = boto.s3.connect_to_region(region)
2626

2727
if not bucket_exists(conn, bucket_name):
28-
conn.create_bucket(bucket_name, location=region)
28+
if region == "us-east-1":
29+
# use "US Standard" region. workaround for https://github.com/boto/boto3/issues/125
30+
conn.create_bucket(bucket_name)
31+
else:
32+
conn.create_bucket(bucket_name, location=region)
2933

3034
elif os.getenv('REGISTRY_STORAGE') == "gcs":
3135
scopes = ['https://www.googleapis.com/auth/devstorage.full_control']

0 commit comments

Comments
 (0)