简体   繁体   中英

AWS S3 Bucket Policy throws Access Denied Error

As per the link https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html --> I was trying to create and host a static page on AWS S3. But I'm having trouble providing public access to my bucket using bucket policy.

So, as soon as I paste

{
  "Version":"2012-10-17",
  "Statement":[{
    "Sid":"PublicReadGetObject",
        "Effect":"Allow",
      "Principal": "*",
      "Action":["s3:GetObject"],
      "Resource":["arn:aws:s3:::mybucket-name.com/*"]
    }]
}

it's throwing me access denied error.

in IAM, to my user id, I have associated below custom policy, but still, I'm getting the error message.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:ListBucket",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::mybucket-name.com",
                "arn:aws:s3:::mybucket-name.com/*"
            ]
        }
    ]
}

I have also linked this policy to my user name as well as role. While creating the bucket, my "block public access" looks like this. 阻止公共访问 Also my ACL button I have provided public access to "List only". ACL

So, can anyone help me what I'm missing here, I have looked into the different proposal provided here, still no luck. Can anyone give me any direction, like without getting lost?

You only assigned yourself permissions to edit content in the bucket. For a list of rights see the S3 docs .

You at least want to add s3:PutBucketPolicy to the list of your user permissions. But s3:PutBucketAcl and s3:PutBucketWebsite might also be useful.

Personally, i would likely just give s3:* to the user setting this up, or you might end up hitting this stumbling block again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM