Aws-cli: aws s3api create-bucket throws error for us-east-2

Created on 12 May 2017  路  16Comments  路  Source: aws/aws-cli

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

documentation guidance s3api service-api

Most helpful comment

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

All 16 comments

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.

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.

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...

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}
                            )

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

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.

@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.

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.

@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

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

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

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

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

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings