我已经看到了很多答案,例如关于“LocationConstraint”的第一个答案。答案是正确的,但只涵盖了一半的情况。我试图包含“LocationConstraint”来解决问题,但仍然遇到同样的错误。这是 Omar Zairi 的第二个回答给了我一个线索。
这里的信息实际上非常令人困惑。当您尝试创建名称已被占用的存储桶时,只有当您配置的区域与已占用名称的存储桶区域相同时,您才会收到消息“请求的存储桶名称不可用”。否则,您会收到“位置约束与此请求发送到的区域特定端点不兼容”。
要查找名称是否已被占用,以及是否已被占用,具有该名称的存储桶位于哪个区域,请查看“the-name.s3.amazonaws.com”的 DNS 记录。
下面我使用一个取名“test8765”来展示我上面提到的内容。希望这对像我一样感到困惑的人有所帮助。
bing@bingstp:~$ 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
bing@bingstp:~$ aws s3api create-bucket --bucket test8765
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.
bing@bingstp:~$ aws s3api create-bucket --bucket test8765 --create-bucket-configuration LocationConstraint=eu-west-1
An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The eu-west-1 location constraint is incompatible for the region specific endpoint this request was sent to.
bing@bingstp:~$ aws s3api create-bucket --bucket test8765 --create-bucket-configuration LocationConstraint=us-west-2
An error occurred (BucketAlreadyExists) when calling the CreateBucket operation: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
bing@bingstp:~$ aws s3api create-bucket --bucket test8765 --create-bucket-configuration LocationConstraint=us-west-1
An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The us-west-1 location constraint is incompatible for the region specific endpoint this request was sent to.
bing@bingstp:~$