![](/img/trans.png)
[英]AWS cli s3api put-bucket-tagging - cannot add tag to bucket unless bucket has 0 tags
[英]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
使用 mb 为我们解决了这个问题
aws s3 mb s3://storage.example.com --region us-west-1
如果您尝试创建一个名称已被使用的存储桶,您也会收到此错误。
因此,尝试为您的存储桶提供一个更独特的名称,然后它应该可以工作(我只是在存储桶名称的末尾添加了数字)。
我看过很多答案,比如关于“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:~$
上面列出的大多数建议可能是IllegalLocationConstraintException
错误发生的原因。 就我而言,通过创建一个与我正在使用的代码具有相同区域的新存储桶,发生并解决了相同的错误。 例如,如果S3 存储桶是在us-east-1
区域中创建的,则您的代码(例如AWS SageMaker notebook instance
也必须从us-east-1
区域中创建。
试试这个:
aws s3api create-bucket --bucket myhosted-cctestdemowebsitetest.com --acl public-read --create-bucket-configuration LocationConstraint=ap-south-1 --region ap-south-1
使用时出现此错误:
aws s3 mb s3:// --region us-east-1
在存储桶名称中添加数字为我修复了它。
s3.create_bucket(Bucket=bucket_name,CreateBucketConfiguration={'LocationConstraint':'us-west-2'})
如果您的位置不是“us-east-1”,则必须在 create_bucket() 中使用 CreateBucketConfiguration={'LocationConstraint':'your location'}。 上面提到了正确的语法。
即使我面临同样的问题。 更改存储桶名称并尝试。 它对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.