An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation

Viewed 6411

Using the aws api I can create a bucket in us-east-1 but not other regions else, why is this ?

$ aws s3api create-bucket --bucket snap2web-12 --region us-east-1
{
    "Location": "/snap2web-12"
}
19:21:27 durrantm u2018 /home/durrantm/Dropbox/_/Michael/cli_scripts 
$ aws s3api create-bucket --bucket snap2web-13 --region us-east-2

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.
19:21:44 durrantm u2018 /home/durrantm/Dropbox/_/Michael/cli_scripts 
$ aws s3api create-bucket --bucket snap2web-14 --region us-west-1

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.
19:23:19 durrantm u2018 /home/durrantm/Dropbox/_/Michael/cli_scripts 
$
1 Answers

Two possible fixes:

Use the s3 command:

aws s3 mb s3://snap2web-13 --region us-east-2

or, according to the s3api examples (emphasis mine):

Regions outside of us-east-1 require the appropriate LocationConstraint to be specified in order to create the bucket in the desired region:

aws s3api create-bucket --bucket snap2web-13 --region us-east-2 --create-bucket-configuration LocationConstraint=us-east-2
Related