簡體   English   中英

無法使用 boto3 創建 s3 存儲桶

[英]Unable to create s3 bucket using boto3

我正在嘗試使用boto3python3創建一個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.

但是,Bucket 不存在,仍然無法創建Bucket。

編輯
我從鏈接中找到了原因,並且我還在答案中發布了該原因以幫助某人。

我在網上看了幾篇文章后得到了它。 一旦滿足該條件,存儲桶名稱應該是全局唯一的,它可以按我的預期工作。
我分享這個是為了幫助像我一樣的人

參考

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM