- Published on
Fix: Access Denied error for ListObjectsV2 in AWS S3
- Authors
- Name
- Ashik Nesin
- @AshikNesin
You might encounter the following error when you don't have the necessary permission for your AWS S3 bucket.
fatal error: An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied`
The fix is straightforward, you just need to grant access for the s3:ListBucket permission.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "s3:ListBucket",
"Effect": "Allow",
"Resource": "arn:aws:s3:::YOUR_BUCKET_NAME"
}
]
}
In a practical world, you'll already have permission like reistricting access to only one bucket. In that case, you just need to add the above as another permission statement.
Here is what it'll look like:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "s3:ListBucket",
"Effect": "Allow",
"Resource": "arn:aws:s3:::YOUR_BUCKET_NAME"
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::YOUR_BUCKET_NAME",
"arn:aws:s3:::YOUR_BUCKET_NAME/*"
]
}
]
}
References
Happy fixing permissions!