I am trying to create an S3 bucket using
aws s3api create-bucket —bucket kubernetes-aws-wthamira-io
It gives this error:
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.
I set the region using aws configure
to eu-west-1
Default region name [eu-west-1]:
but it gives the same error. How do I solve this?
I use osx terminal to connect aws
You'll also get this error if you're trying to create a bucket with a name that's already been taken.
So try giving your bucket a more unique name and then it should work (I just added digits to the end of the bucket name).
Using mb solved the issue for us
aws s3 mb s3://storage.example.com --region us-west-1
try this:
Regions outside of
us-east-1
require the appropriateLocationConstraint
to be specified in order to create the bucket in the desired region.https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html
Most of the suggestions listed above could be a reason for the
IllegalLocationConstraintException
error to happen. In my case, the same error happened and solved by creating a new bucket with the same region as that of the code I am working with. For instance, if S3 bucket is created inus-east-1
region, your code e.g., theAWS SageMaker notebook instance
has to be also created fromus-east-1
region.I have seen many answers like the first one about "LocationConstraint". The answer is correct, but only covers half the case. I tried to include "LocationConstraint" to solve the problem but still got the same error. It's Omar Zairi's second answer gave me a clue.
The message here is in fact very confusing. When you are trying to create a bucket with a name that's already taken, only when your configured region is the same as the bucket with the already taken name's region, you receive the message "The requested bucket name is not available". Otherwise, you receive "location constraint is incompatible for the region specific endpoint this request was sent to".
To find if a name is already taken, and in case it's taken, which region the bucket with that name is in, look at the DNS record of "the-name.s3.amazonaws.com".
Below I use a taken name "test8765" to show what I mentioned above. Hope this helps whoever got confused like I did.