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 回答
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
专家
已回答 8 个月前
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
专家
已回答 8 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则