Skip to content
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

aws s3api create-bucket throws error for us-east-2 #2603

Closed
mickengland opened this issue May 12, 2017 · 22 comments
Closed

aws s3api create-bucket throws error for us-east-2 #2603

mickengland opened this issue May 12, 2017 · 22 comments
Labels
documentation This is a problem with documentation. guidance Question that needs advice or information. s3api service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@mickengland
Copy link

aws s3api create-bucket --bucket dev-xxxx-com-state --region us-east-2

A client error (IllegalLocationConstraintException) occurred when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

Works fine with us-east-1.

aws --version
aws-cli/1.7.45 Python/2.7.10 Darwin/16.5.0

@JordonPhillips
Copy link
Member

You need to specify the location constraint for every region except us-east-1. See the docs for examples.

Alternatively, you can use mb which will handle that for you.

@rramani7
Copy link

rramani7 commented Oct 5, 2017

Even though I used LocationConstraint but ended up getting exceptions , checking details of parameter suggest we have finite list for location. I can use AWS web console to create bucket with region as us-east-2 but can't create bucket through awscli create-bucket even after using locationconstraint with region as us-east-2.

{
"LocationConstraint": "EU"|"eu-west-1"|"us-west-1"|"us-west-2"|"ap-south-1"|"ap-southeast-1"|"ap-southeast-2"|"ap-northeast-1"|"sa-east-1"|"cn-north-1"|"eu-central-1"
}

mb seems to be alternate method and going to try that but awscli create-bucket should fix this inconsistency.

@n3ph
Copy link

n3ph commented Nov 5, 2017

Bump.

Facing same problem with duplicity / boto here... (eu-central-1)
On Bucket creation attempt I get:

<Error><Code>IllegalLocationConstraintException</Code><Message>The EU location constraint is incompatible for the region specific endpoint this request was sent to.</Message><RequestId>237A164CEBB07087</RequestId><HostId>oEDaB4OT/MlUGIJ0j1GJH7ezXqldUZa2sFKRPz3iHqAZsnpOyKiRGDV69hP/FTXK1j90ogcJB/Y=</HostId></Error>

If I create the Bucket manually everything is working fine...

Please have a look at your log files...

@adv4000
Copy link

adv4000 commented Dec 5, 2017

I fixed it in Boto3:

os.environ['AWS_DEFAULT_REGION'] = 'eu-west-2'
myS3 = boto3.resource('s3')
results = myS3.create_bucket(
                             Bucket='zxvxdvx.gsdrgerrrczxczxcgggzxczxczxc',
                             CreateBucketConfiguration={'LocationConstraint': AWS_DEFAULT_REGION}
                            )

@shahzeb1
Copy link

shahzeb1 commented Sep 18, 2018

For those of you looking to create a bucket via the CLI, run this:

aws s3api create-bucket --bucket my-bucket-name --region us-west-2 --create-bucket-configuration LocationConstraint=us-west-2

@thetomasz
Copy link

Posting this here for posterity. Bucket names are GLOBALLY unique! AWS CLI will give you the IllegalLocationConstraintException if you collide with an already existing bucket and you've specified a region different than the region of the already existing bucket. If you happen to guess the correct region of the existing bucket it will give you the BucketAlreadyExists exception.

@jezen
Copy link

jezen commented Oct 10, 2018

@thetomasz I can't believe my luck that you posted this 21 hours before I had exactly the same issue. Thank you so much; this was exactly my problem.

@Arnold1
Copy link

Arnold1 commented Oct 12, 2018

the following doesnt work for me:
aws s3api create-bucket --bucket avengers-docker-eb --region us-east-1 --create-bucket-configuration LocationConstraint=us-east-1

error:
An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The us-east-1 location constraint is incompatible for the region specific endpoint this request was sent to.

@bingtimren
Copy link

bingtimren commented Jan 3, 2019

@thetomasz thank you so much for your post! I wish I had first seen your post before finally figured this out myself. The message is truly confusing, even misleading.

To find out if a name is already taken and figure out which region, if it's indeed taken, the bucket is located in, look at the DNS record of the name "your-bucket-name.s3.amazonaws.com". For example:

$ dig test8765.s3.amazonaws.com

; <<>> DiG 9.11.3-1ubuntu1.3-Ubuntu <<>> test8765.s3.amazonaws.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39766
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;test8765.s3.amazonaws.com.	IN	A

;; ANSWER SECTION:
test8765.s3.amazonaws.com. 2016	IN	CNAME	s3-us-west-2-w.amazonaws.com.
s3-us-west-2-w.amazonaws.com. 5	IN	A	52.218.216.10

;; Query time: 16 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Thu Jan 03 15:16:11 AEDT 2019
;; MSG SIZE  rcvd: 99

@diehlaws diehlaws added guidance Question that needs advice or information. service-api This issue is due to a problem in a service API, not the SDK implementation. and removed api-question labels Jan 4, 2019
@JosiahEarl
Copy link

Well this explains why my bucket name of "testbucket" wouldn't go through ;) Thanks guys.

@Schmidtbit
Copy link

I had the same issue. Using aws s3 mb s3://<bucket-name> --region us-east-2 worked for me.

@dlandi
Copy link

dlandi commented May 24, 2019

I just encountered this bug, myself. Come on AWS. Fix it. If the error is a global naming collision, then say so.

@venu6644
Copy link

I get this error when I do Put Bucket encryption in my lambda script. Can someone help

An error occurred (IllegalLocationConstraintException) when calling the PutBucketEncryption operation: The ap-east-1 location constraint is incompatible for the region specific endpoint this request was sent to.: ClientError

@dapseen
Copy link

dapseen commented Oct 14, 2019

For those of you looking to create a bucket via the CLI, run this:

aws s3api create-bucket --bucket my-bucket-name --region us-west-2 --create-bucket-configuration LocationConstraint=us-west-2

worked for me

@torressam333
Copy link

For everyone trying to create the bucket in us-east-1 just change the --region us-east-2 and it created perfectly and was visible in my aws console.

@knowledgeshare99
Copy link

Even its worked for me after passing """"--create-bucket-configuration LocationConstraint=us-west-2"""' parameter options

aws s3api create-bucket --bucket my-bucket-name --region us-west-2 --create-bucket-configuration LocationConstraint=us-west-2

lucamilanesio pushed a commit to GerritCodeReview/aws-gerrit that referenced this issue Jul 7, 2020
S3 bucket creation for regions other than us-east-1 needs additional
LocationConstraint configuration. However this must not be set when the
region is us-east-1.

Details can be found here[1]

[1] aws/aws-cli#2603

Bug: Issue 13095
Change-Id: I3d4fc5a6e8ec536001aec22c8d0e36c17523bb87
pierrebeitz added a commit to mesosphere/dcos-docs-site that referenced this issue Oct 14, 2020
pierrebeitz added a commit to mesosphere/dcos-docs-site that referenced this issue Oct 15, 2020
facebook-github-bot pushed a commit to pytorch/torchx that referenced this issue May 18, 2021
…et configuration on mock s3 create_bucket call

Summary:
Fixes s3_test.py. Used to fail with

```
  2) torchx.aws.test.s3_test.S3Test: test_storage_provider_file
    1) AssertionError:
      File "torchx/aws/test/s3_test.py", line 41, in test_storage_provider_file
        init_plugin(None)
      File "torchx/aws/s3.py", line 91, in init_plugin
        register_storage_provider(S3(boto3.Session()))
      File "torchx/runtime/storage.py", line 58, in register_storage_provider
        assert provider.SCHEME not in _PROVIDERS
```

because the test has side-effects when setting the global `_PROVIDERS`.

Also for regions other than `us-east-1` location constraint must be set on create-bucket call. See: aws/aws-cli#2603

Reviewed By: tierex

Differential Revision: D28499845

fbshipit-source-id: 6dfae7ac06930ff83bc7639cfeeef6f30ddc82ed
@tbanj
Copy link

tbanj commented Jun 15, 2021

@dapseen thanks your solution works for me though I had extra parameter since I want to make the bucket to be publicly readable and writeable for learning purpose then also pass profile name parameter.

aws s3api create-bucket --bucket tbanj-0332124-test-bucket --acl public-read-write --region eu-west-1 --profile cloudform-tutor --create-bucket-configuration LocationConstraint=eu-west-1

@pcgeek86
Copy link

I had to add --create-bucket-configuration LocationConstraint=us-west-2 to the AWS CLI command.

Why is this necessary? Seems like a pointless parameter, poor customer experience.

@kdaily
Copy link
Member

kdaily commented Dec 28, 2021

@pcgeek86, thanks for the comment. Unfortunately this command is calling the S3 API directly and this requirement comes from there - you can see the same signature in the S3 CreateBucket API documentation:

https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html#API_CreateBucket_RequestSyntax

The AWS CLI provides the aws s3 mb, which handles this for you by getting the value set for the --region. You can see that we use the CreateBucket command to do this, and add this parameter to the request body for you here.

@pcgeek86
Copy link

That's odd. The New-S3Bucket command in the AWS PowerShell module doesn't require that extra parameter. I'm pretty sure it's just calling CreateBucket under the hood. 🤷🏻‍♂️

New-S3Bucket -BucketName (New-Guid).Guid -Region us-west-2

@AlessioCampanelli
Copy link

Posting this here for posterity. Bucket names are GLOBALLY unique! AWS CLI will give you the IllegalLocationConstraintException if you collide with an already existing bucket and you've specified a region different than the region of the already existing bucket. If you happen to guess the correct region of the existing bucket it will give you the BucketAlreadyExists exception.

thanks a lot! brilliant suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This is a problem with documentation. guidance Question that needs advice or information. s3api service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests