-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behavior when trying to create an S3 bucket in us-east-1 #125
Comments
This is an artifact of the underlying S3 API and the fact that it doesn't accept Comparing our docs to the S3 API Reference docs (http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUT.html) it looks like we aren't documenting enum types, which I think would have helped here. We'll look into updating our docs. |
I disagree that this shouldn't be fixed within Boto3/core, even if the REST API behaves this way. Having one special region that should be assumed default and raises a confusing Exception when explicitly named violates the Zen of Python
Creating a boto3.client("ec2") will raise an exception for not specifying a region_name, so it's not as if the rest of Boto3 assumes us-east-1 as default. Of course it's trivial for me just to add the below quirk now that I know of this behavior:
But why not add the quirk to Boto3's s3.create_bucket() instead of forcing every developer that ever creates S3 buckets to discover the behavior and re-implement the quirk in their own code? I haven't looked at the Boto3/core code yet, but I would imagine that adding something like this would fix it and prevent numerous other people from running into the same issue:
|
Sorry about that. I wasn't suggesting we weren't open to any client side updates, just wanted to explain the current behavior. The other thing I forgot to mention is we don't actually have specific code for this method (or any method in general). We actually dynamically generate methods at runtime based on a shared JSON Description. So this essentially means that we surface the exact REST API in boto3 (and all the semantics of the underlying REST API). We can however add customizations if necessary. My main hesitation here is that this isn't technically us-east-1, at least in the sense of how other AWS services refer to us-east-1. Our docs refer to this as "US Standard" and say that this can either be "facilities in Northern Virginia or the Pacific Northwest" (http://docs.aws.amazon.com/general/latest/gr/rande.html). This potentially false consistency could be confusing for customers as well. We'll consider this though. Thanks for the feedback. |
It's been a year. Have you figured out what to do about this problem? It still presents a poor developer experience, having to work around an API inconsistency in an interface (boto) that is ostensibly meant to hide API behaviors. (he said, having spent a day debugging a problem caused by this bug) |
On
Similarly, one cannot pass an empty dict
It seems that you must omit the field. Similarly, if not using other
|
I sent amazon feedback to fix their documentation on the default region. I encourage others to do so. I can't believe this poor design decision on Amazon's part. |
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"
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"
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"
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"
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"
is this issue fixed? |
@tanzeelrana: |
why was this closed? This issue still exists. |
…ameters depending on region - see boto/boto3#125
After about 5 years, this is still not even fixed in the documentation, e.g.
heavy sigh - why is this issue closed? The documentation fails to explain that if region_name == "us-east-1":
s3_client.create_bucket(Bucket=bucket_name)
else:
location = {"LocationConstraint": region_name}
s3_client.create_bucket(
Bucket=bucket_name,
CreateBucketConfiguration=location
) |
March 2021 - checking in. This is still an issue. 🙄 |
Hey guys, I created this other ticket on AWS-CLI. I saw this error on the web console too, looks like an AWS internal error. Comment on the ticket to make AWS fix it or clarify the error. |
* workaround for boto/boto3#125 Co-authored-by: Adam Novak <anovak@soe.ucsc.edu>
Version info:
boto3 = 0.0.19 (from pip)
botocore = 1.0.0b1 (from pip)
Python = 2.7.9 (from Fedora 22)
I have no problem creating S3 buckets in us-west-1 or us-west-2, but specifying us-east-1 gives InvalidLocationConstraint
Also trying with a s3 client connected directly to us-east-1:
When I do not specify a region, the bucket is created in us-east-1 (verified in the web console):
...but the bucket returns None for LocationConstraint:
us-east-1 is listed as a valid region when I enumerate the regions:
The text was updated successfully, but these errors were encountered: