调用 CreateBucket 操作时发生错误(IllegalLocationConstraintException)

Mic*_*ant 2 amazon-s3 amazon-web-services

使用 aws api 我可以在 us-east-1 而不是其他区域创建一个存储桶,这是为什么?

$ 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 
$
Run Code Online (Sandbox Code Playgroud)

std*_*bar 9

Two possible fixes:

Use the s3 command:

aws s3 mb s3://snap2web-13 --region us-east-2
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)