无法使用Boto3创建S3存储桶

时间:2018-10-05 10:55:06

标签: python-3.x amazon-web-services amazon-s3 boto3

我正在尝试使用 boto3 python3 创建一个 aws 存储桶。 create_bucket()是我使用的方法。仍然出现错误botocore.errorfactory.BucketAlreadyExists

我的代码:

import boto3

ACCESS_KEY = 'theaccesskey'
SECRET_KEY = 'thesecretkey'

S3 = boto3.client('s3', 
                   aws_access_key_id = ACCESS_KEY, 
                   aws_secret_access_key = SECRET_KEY)

response = S3.create_bucket(Bucket='mynewbucket',
           CreateBucketConfiguration={'LocationConstraint':'ap-south-1'})

错误:

botocore.errorfactory.BucketAlreadyExists: 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.

但是,存储桶不存在,创建存储桶仍然失败。

编辑
我从link中找到了原因,并且还将其张贴在答案中以帮助他人。

1 个答案:

答案 0 :(得分:0)

我在网上阅读了几篇文章后就明白了。一旦满足条件,存储桶名称就应该全局唯一
我分享这是为了帮助像我这样的人感到惊奇

Reference

相关问题