调用ListBucket操作时发生错误(AccessDenied):拒绝访问

2024-05-23 18:58:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在一个项目中工作,目标是从AmazonS3获取报告。目前,我正在尝试访问S3位置,以检查我的可用桶列表

我在python中工作,我已经在提示符下设置了所有凭据:aws configure

在我的python文件中,当我尝试使用代码列出我的所有存储桶时:

import boto3
s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
    print (bucket.name)

我得到了这个错误:

Traceback (most recent call last): File "C:\Users\bakpovo\testAmazon.py", line 3, in for bucket in s3.buckets.all(): File "C:\Users\bakpovo\AppData\Local\Programs\Python\Python38\lib\site-packages\boto3\resources\collection.py", line 83, in iter for page in self.pages(): File "C:\Users\bakpovo\AppData\Local\Programs\Python\Python38\lib\site-packages\boto3\resources\collection.py", line 161, in pages pages = [getattr(client, self._py_operation_name)(**params)] File "C:\Users\bakpovo\AppData\Local\Programs\Python\Python38\lib\site-packages\botocore\client.py", line 276, in _api_call return self._make_api_call(operation_name, kwargs) File "C:\Users\bakpovo\AppData\Local\Programs\Python\Python38\lib\site-packages\botocore\client.py", line 586, in _make_api_call raise error_class(parsed_response, operation_name) botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied

有人知道发生了什么吗?我的皱纹不好吗

谢谢


Tags: nameinpys3liblocallinecall
1条回答
网友
1楼 · 发布于 2024-05-23 18:58:18

谢谢大家的回答。我解决了我的问题。 我刚刚在shell语法中添加了s3位置,如下所示:

aws s3 ls s3://aps-external-xxxx/aps-downloadxxx-xxx-e306fd2/

这就是工作

相关问题 更多 >