aws s3api create-bucket —bucket make exception

aws s3api create-bucket —bucket make exception

我正在尝试使用

创建 S3 存储桶

aws s3api create-bucket —bucket kubernetes-aws-wthamira-io

它给出了这个错误:

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.

我使用 aws configure 将区域设置为 eu-west-1

Default region name [eu-west-1]: 

但它给出了同样的错误。我该如何解决?

我用osx终端连接aws

试试这个:

aws s3api create-bucket --bucket kubernetes-aws-wthamira-io --create-bucket-configuration LocationConstraint=eu-west-1

us-east-1 以外的区域需要指定适当的 LocationConstraint 才能在所需区域创建存储桶。

https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html

如果您尝试创建一个名称已被占用的存储桶,您也会遇到此错误。

因此,请尝试为您的存储桶起一个更独特的名称,然后它应该可以正常工作(我只是在存储桶名称的末尾添加了数字)。

关于"LocationConstraint",我看到了很多像第一个这样的答案。答案是正确的,但只涵盖了一半的情况。我试图包含 "LocationConstraint" 来解决问题,但仍然出现相同的错误。这是 Omar Zairi 的第二个回答给了我一个线索。

这里的信息其实很混乱。当您尝试创建名称已被占用的存储桶时,只有当您配置的区域与名称已被占用的区域的存储桶相同时,您才会收到消息 "The requested bucket name is not available"。否则,您会收到 "location constraint is incompatible for the region specific endpoint this request was sent to".

要查找某个名称是否已被占用,如果已被占用,具有该名称的存储桶位于哪个区域,请查看 "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:~$ 

上面列出的大多数建议可能是导致 IllegalLocationConstraintException 错误发生的原因。 在我的例子中,通过创建一个与我正在使用的代码具有相同区域的新存储桶,发生并解决了同样的错误。 例如,如果 S3 bucket 是在 us-east-1 区域创建的,那么您的代码,例如 AWS SageMaker notebook instance 也必须从 us-east-1 区域创建。

使用 mb 为我们解决了问题

aws s3 mb s3://storage.example.com --region us-west-1

我也遇到了同样的问题。更改存储桶名称并尝试。它对我有用。

试试这个:

aws s3api create-bucket --bucket myhosted-cctestdemowebsitetest.com --acl public-read --create-bucket-configuration LocationConstraint=ap-south-1 --region ap-south-1