AccessDenied for ListObjects for S3 bucket when permissions are s3:*

前端 未结 13 788
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 22:02

I am getting:

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

When I try to get folder from

13条回答
  •  鱼传尺愫
    2021-01-29 22:13

    You have given permission to perform commands on objects inside the S3 bucket, but you have not given permission to perform any actions on the bucket itself.

    Slightly modifying your policy would look like this:

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

    However, that probably gives more permission than is needed. Following the AWS IAM best practice of Granting Least Privilege would look something like this:

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

提交回复
热议问题