我正在使用AWS SDK for Python(boto3)自动设置某些AWS服务,并遇到一个非常简单的创建S3存储桶的问题。
我仔细检查过以下内容:
~/.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.
我觉得我错过了一些非常愚蠢的东西,但我不能想到它的生命或者我做错了什么。
答案 0 :(得分:17)
存储区名称是全局到区域的,并非特定于您的帐户。 因此,您需要选择一个根本不存在的名称。我建议使用前缀