簡體   English   中英

AWS S3 ListBuckets 操作:拒絕訪問

[英]AWS S3 ListBuckets operation: Access Denied

我正在嘗試按照boto3 文檔列出存儲桶。

import boto3

s3 = boto3.client(service_name = 's3',
                  region_name = 'us-east-2',
                  aws_access_key_id='xxxxxx',
                  aws_secret_access_key= 'xxxxx'
                 )

response = s3.list_buckets()

# Output the bucket names
print('Existing buckets:')
for bucket in response['Buckets']:
    print(f'  {bucket["Name"]}')

但事實證明有一個錯誤,它說

ClientError: An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied

我為這個錯誤找到了一些類似的帖子,但我仍然不知道如何解決我的錯誤。 任何幫助,將不勝感激。

我試圖運行你的代碼,一切正常。 而且你不必指定 region_name 因為無論如何你都會得到所有的桶。 然后我試圖從我的用戶那里刪除對 s3 的權限並得到同樣的錯誤。 我猜你是因為你的用戶政策而遇到這樣的錯誤。 您應該將您的政策內容附加到問題中。

暫無
暫無

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

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