为什么 AWS 告诉我 BucketAlreadyExist,而实际上并非如此?



我正在使用AWS SDK for Python (boto3)自动化一些AWS服务的设置过程中,遇到了一个创建S3 bucket的非常简单的问题。

我仔细检查了以下内容:

  • ~/.aws/credentials,我有一个访问密钥ID和秘密访问密钥集。
  • 此访问密钥ID/秘密访问密钥用于属于组的帐户,该组附加了以下策略:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "*",
          "Resource": "*"
        }
      ]
    }
    
  • 没有名称为"我正在尝试创建
  • "的桶

然而,当我尝试运行这个非常简单的操作时,它失败了:

>>> import boto3
>>> client = boto3.client('s3')
>>> response = client.create_bucket('staging')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yiqing/Repos/ansible-home/roles/osx/files/virtualenvs/obaku/lib/python2.7/site-packages/botocore/client.py", line 157, in _api_call
    "%s() only accepts keyword arguments." % py_operation_name)
TypeError: create_bucket() only accepts keyword arguments.
>>> response = client.create_bucket(Bucket='staging')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yiqing/Repos/ansible-home/roles/osx/files/virtualenvs/obaku/lib/python2.7/site-packages/botocore/client.py", line 159, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/yiqing/Repos/ansible-home/roles/osx/files/virtualenvs/obaku/lib/python2.7/site-packages/botocore/client.py", line 494, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: 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.

我觉得我错过了一些非常愚蠢的事情,但我怎么也想不出可能是什么,或者我做错了什么。

桶名是全局的,而不是特定于您的帐户。所以你需要选择一个根本不存在的名字。我建议使用前缀

最新更新