Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ClientError:调用ListObjects操作时发生错误(AccessDenied):拒绝访问_Python_Amazon S3_Jupyter Notebook_Parquet - Fatal编程技术网

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

Python ClientError:调用ListObjects操作时发生错误(AccessDenied):拒绝访问,python,amazon-s3,jupyter-notebook,parquet,Python,Amazon S3,Jupyter Notebook,Parquet,我正在jupyter笔记本中使用python。 我试图从aws s3存储桶中访问几个拼花地板文件,并将它们全部转换为一个json文件。我知道我可以访问数据,但我得到: ClientError: An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied 以下是我的代码: import boto3 s3_resource = boto3.resource('s3') s3_cli

我正在jupyter笔记本中使用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')
我不确定被拒绝的访问是从哪里来的。非常感谢你

您可以遵循此操作,并将以下策略附加到用户/角色

{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Effect":"Allow",
         "Action":[
            "s3:ListBucket"
         ],
         "Resource":"arn:aws:s3:::my-bucket"
      }
   ]
}
您可以遵循此操作,并将以下策略附加到用户/角色

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

您需要向IAM用户/角色授予
s3:ListBucket
权限。谢谢!我在前面的代码块中调用了“for obj in bucket.objects.all():”,这不意味着我有权访问ListBucket吗?您需要向IAM用户/角色授予
s3:ListBucket
权限。谢谢!我在前面的一段代码中调用了“bucket.objects.all():”中的obj,这不意味着我有权访问ListBucket吗?我相信我有这个权限,因为我调用的是“bucket.objects.all():”中的obj,可能还有什么其他的吗?我相信我有这个权限,因为我调用的是“bucket.objects.all():”中的obj,还有什么别的可能吗?