- Newest
- Most votes
- Most comments
You can’t use OAC when the S3 bucket is configured as a website (custom) origin. The S3 bucket in cloudfront has to be configured as a regular S3 bucket.
- If your origin is an Amazon S3 bucket configured as a website endpoint, you must set it up with CloudFront as a custom origin. That means you can't use OAC (or OAI).
Cloudfront doesn't work with static web host S3 endpoints, meaning that your endpoint should look like this <bucketname>.s3.us-east-1.amazonaws.com.
In fact you can disable static website hosting.
In your bucket access use this configuration
And in the bucket ACL write this policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<bucketname>/*"
}
]
}
Object Ownership should be Bucket owner enforced
After that in you Cloudfront distribution
Your origins should look like this with the s3 endpoint (OAC)
In you Behaviors
Finally in the settings of your distribution you should add
Alternate domain name (CNAME) - optional (the one you have registered at Route53 which is your domain it has to be of type CNAME)
And in custom ssl you should load your ACM certificate of the domain you want
Be sure to register in Route53 the distribution link that Cloudfront gives you (you can also access to your content with this link if you dont have anything related to CORS that might block your content)
Relevant content
asked 2 years ago

The bucket policy statement allowing everyone, including completely authenticated users, to read from the bucket, as well as advice about disabling two of the Block Public Access settings for the bucket is not the way OAC is configured. The policy statement
AllowCloudFrontServicePrincipalin the original statement is correct, and when it is in effect, all the Block Public Access options can and should be selected for the bucket, and is advisable to do also at the account level, applying to all buckets. CloudFront will use OAC for authenticated (not anonymous) access to the bucket.Leo is correct. This bucket policy is not least privileged and not limited to cloudfront