Getting Access Denied when calling the PutObject operation with bucket-level permission

前端 未结 14 1326
醉话见心
醉话见心 2020-12-12 13:37

I followed the example on http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html#iam-policy-example-s3 for how to grant a user access to just one buck

14条回答
  •  -上瘾入骨i
    2020-12-12 13:42

    I was just banging my head against a wall just trying to get S3 uploads to work with large files. Initially my error was:

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

    Then I tried copying a smaller file and got:

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

    I could list objects fine but I couldn't do anything else even though I had s3:* permissions in my Role policy. I ended up reworking the policy to this:

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "s3:PutObject",
                    "s3:GetObject",
                    "s3:DeleteObject"
                ],
                "Resource": "arn:aws:s3:::my-bucket/*"
            },
            {
                "Effect": "Allow",
                "Action": [
                    "s3:ListBucketMultipartUploads",
                    "s3:AbortMultipartUpload",
                    "s3:ListMultipartUploadParts"
                ],
                "Resource": [
                    "arn:aws:s3:::my-bucket",
                    "arn:aws:s3:::my-bucket/*"
                ]
            },
            {
                "Effect": "Allow",
                "Action": "s3:ListBucket",
                "Resource": "*"
            }
        ]
    }
    

    Now I'm able to upload any file. Replace my-bucket with your bucket name. I hope this helps somebody else that's going thru this.

提交回复
热议问题