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

Viewed 12251

I am working with python in a jupyter notebook. I am trying to access several parquet files from an aws s3 bucket and convert them all into one json file. I know I have access to the data, but I am getting:

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

Here is the code I have:

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')

I am not sure where the access denied is coming from. Thank you so much!

1 Answers

You can follow this link, and attach the following policy to the user/role.

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