What permissions needed to list and upload to S3 via CLI

0

Hi, I have AmazonS3FullAccess permissions on a bucket. I am trying to connect to it and list objects but I get an error. 'An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied'

So do I need any other permissions to allow me to list and upload files?

Thanks

2 Answers
0

Make sure your IAM role/user has s3:ListBucket permission added for that bucket, where you are listing/uploading objects.

{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "Stmt1546506260896",
    "Action": "s3:ListBucket",
    "Effect": "Allow",
    "Resource": "arn:aws:s3:::AWSDOC-EXAMPLE-BUCKET"
  }]
}

Hope this helps.

Comment here if you have additional questions, happy to help.

Abhishek

profile pictureAWS
EXPERT
answered 8 months ago
0

Hi,

You need the following policy to list a bucket

{
  "Statement": [
    {
        "Sid": "some_id",
        "Effect": "Allow",
        "Action": [
            "s3:*"
        ],
        "Resource": [
            "arn:aws:s3:::bucketname",
            "arn:aws:s3:::bucketname/*"
        ]
    }
  ] 
}

The most restrictive policy would be (if you feel that "Action": ["s3:*"] is too broad:

{
  "Version": "2012-10-17",
  "Statement": [
      {
          "Effect": "Allow",
          "Action": [
              "s3:ListBucket"
          ],
          "Resource": [
              "arn:aws:s3:::bucketname"
          ]
      },
      {
          "Effect": "Allow",
          "Action": [
              "s3:PutObject"
          ],
          "Resource": [
              "arn:aws:s3:::bucketname/*"
          ]
      }
  ]
}

By using any of the two, you do not need the policy AmazonS3FullAccess (managed by AWS) anymore

Best,

Didier

profile pictureAWS
EXPERT
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions