AWS Bucket Policy Invalid Resource

2020-08-03 04:23发布

问题:

I'm having some trouble with AWS Bucket policies, I followed the instruction and it doesn't let me set the policy, so I can't get my domain to work with the buckets.

Here is a picture. The tutorial told me to replace example.com with my bucket name.

I've been trying to set up my buckets with my domain for over a month now and I just can't seem to get it going. I already purchased my domain, and it's the exact domain name I want, so I don't want to be forced to go to Bluehost with a new domain.

回答1:

It is quite simple:

  • Your bucket is called www.justdiditonline.com
  • Your bucket policy is attempting to create a rule for a bucket named justdiditonline.com
  • The bucket names do not match

Solution: Use a policy with the correct bucket name:

{
  "Id": "Policy1",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1",
      "Action": [
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::www.justdiditonline.com/*",
      "Principal": "*"
    }
  ]
}

I notice you have another bucket called justdiditonline.com. Your existing policy would work on that bucket.

The Setting Up a Static Website Using a Custom Domain instructions detail what to do, and they work fine with an external DNS service using a CNAME to point to the static website URL. The main steps are:

  • Create a bucket with the domain name www.justdiditonline.com
  • Add a bucket policy to make content public, or make sure the individual objects you want to serve are publicly readable
  • Activate Static Website Hosting on the bucket, which will return a URL like: www.justdiditonline.com.s3.amazonaws.com
  • Create a DNS entry for www.justdiditonline.com with a CNAME pointing to the Static Website Hosting URL