【问题标题】:ClientError: An error occurred (AccessDenied) when calling the ListObjects operation: Access DeniedClientError:调用 ListObjects 操作时发生错误 (AccessDenied):访问被拒绝
【发布时间】:2020-07-16 17:33:28
【问题描述】:

我在 jupyter notebook 中使用 python。 我正在尝试从 aws s3 存储桶访问多个镶木地板文件并将它们全部转换为一个 json 文件。我知道我可以访问数据,但我得到了:

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

这是我的代码:

import boto3

s3_resource = boto3.resource('s3')

s3_client = boto3.client('s3')
bucket = s3_resource.Bucket(name='my-bucket')

all_objects = s3_client.list_objects(Bucket = 'my-bucket', Prefix = 'Files.parquet')

我不确定拒绝访问的来源。非常感谢!

【问题讨论】:

  • 您需要将s3:ListBucket 权限授予IAM 用户/角色。
  • 谢谢!我在前面的代码块中调用了上面的“for obj in bucket.objects.all():”,这是否意味着我可以访问 ListBucket?

标签: python amazon-s3 jupyter-notebook parquet


【解决方案1】:

您可以关注此link,并将以下策略附加到用户/角色。

{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Effect":"Allow",
         "Action":[
            "s3:ListBucket"
         ],
         "Resource":"arn:aws:s3:::my-bucket"
      }
   ]
}

【讨论】:

  • 我相信我确实有这个权限,因为我之前在调用'for obj in bucket.objects.all():',还有其他可能吗?
猜你喜欢
  • 2021-09-23
  • 1970-01-01
  • 2021-04-13
  • 2018-07-12
  • 1970-01-01
  • 2018-12-09
  • 1970-01-01
  • 1970-01-01
  • 2020-04-02
相关资源
最近更新 更多