Aws-cli: aws s3 mb fails due to IllegalLocationConstraintException

Created on 15 Sep 2018  路  8Comments  路  Source: aws/aws-cli

When I try to create a bucket from the aws cli, I get an error that I cannot resolve. Any hints? Thanks!

Command: aws s3 mb s3://bucket-name --region us-east-1
Error: make_bucket failed: s3:///bucket-name An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
Version: aws-cli/1.16.14 Python/3.6.6 Darwin/17.6.0 botocore/1.12.4

confusing-error duplicate feature-request

Most helpful comment

I was able to create the bucket by changing the name. I think this error was thrown because the name was not unique, but the error message was completely misleading. I only found out the name issue by trying to create it via the AWS web console. May want to update this error message

All 8 comments

I was able to create the bucket by changing the name. I think this error was thrown because the name was not unique, but the error message was completely misleading. I only found out the name issue by trying to create it via the AWS web console. May want to update this error message

Thanks for reaching out to us about this @holtc. This error occurs as a result of the AWS CLI getting redirected to the endpoint where the existing bucket was created. After the redirect occurs the request is not updated with the location constraint of the new region, resulting in the location constraint and the S3 endpoint not matching up which in turn causes the IllegalLocationConstraint exception.

This behavior is something we are aware of and plan to change, however in the meantime you can override the endpoint URL for the request with --endpoint-url (e.g. aws s3 mb s3://bucket-name --region us-east-1 --endpoint-url https://s3.us-east-1.amazonaws.com). Please do let us know if using this option does not work as expected from your end.

@diehlaws Your suggestion worked for me. Thank you.

@diehlaws That workaround worked for me. It'd be nice if the client got fixed soon or at least had a doc pointer in the error message

Closing this issue as we are tracking the process under issue #3723. It has also been escalated internally to our documentation writers.

I have also noticed, that if you create bucket with name without extension (bucketname.extension) - it causes the same error

the answer for @diehlaws worked for me.

@justnance this issue should be reopened. The title of #3723 doesn't reflect the problem with s3 mb that is still not fixed. For a high level tool the s3 mb command could include the workaround.

Was this page helpful?
0 / 5 - 0 ratings