stackedodds
stackedodds

Reputation: 15

How can I resolve AWS::S3::Errors:: Access Denied?

Hi I've followed the link below to configure paperclip with AWS S3 but I keep getting a "AWS::S3::ERRORS::AccessDenied (Access Denied):" from the heroku logs. If I remove my block public access settings, I am able to upload an image to my S3 folder without fail.

May I know if there's anything I should configure to make this work properly? My ENV files are 100% correct as they were able to connect when I removed block all public access..

I currently have a bucket policy like that and no CORS configuration

{
"Version": "2012-11-17",
"Id": "Policy1231xxx1231xx",
"Statement": [
    {
        "Sid": "Stmt1123123123",
        "Effect": "Allow",
        "Principal": {
            "AWS": "arn:aws:iam::2123123123:user/someuser"
        },
        "Action": "s3:*",
        "Resource": "arn:aws:s3:::somename"
    }
]

}

Upvotes: 1

Views: 978

Answers (1)

Mani Ezhumalai
Mani Ezhumalai

Reputation: 469

Change your resource parameter like this

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "S3Permissions",
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::awsexamplebucket/*",
        "arn:aws:s3:::awsexamplebucket"
      ]
    }
  ]
}

Also you can refer this link to define your bucket policy https://aws.amazon.com/premiumsupport/knowledge-center/s3-access-denied-bucket-policy/

Upvotes: 2

Related Questions