- Newest
- Most votes
- Most comments
Based on your setup description, there are a few potential causes for the 403 Forbidden error you're experiencing:
-
Static Website Hosting with OAI/OAC Conflict: You mentioned that you have static website hosting enabled on your S3 bucket while also using an Origin Access Identity (OAI). This is a common issue - when using OAI or Origin Access Control (OAC), you should not have static website hosting enabled on the bucket. These two features don't work together properly.
-
Origin Configuration: Your CloudFront distribution might be pointing to the S3 website endpoint instead of the S3 REST API endpoint. When using OAI/OAC, your origin should be the S3 bucket REST endpoint (e.g.,
my-awesome-guide-bucket.s3.amazonaws.com), not the website endpoint (e.g.,my-awesome-guide-bucket.s3-website-region.amazonaws.com). -
Default Root Object: Make sure you've set
index.htmlas the default root object in your CloudFront distribution settings. -
Permissions Issue: The bucket policy looks correct, but ensure that the CloudFront distribution ID and account ID in the condition are accurate.
To fix this issue:
-
Disable static website hosting on your S3 bucket if you want to use OAI/OAC (recommended for security).
-
Ensure your CloudFront origin is set to the S3 bucket REST API endpoint.
-
Verify that your CloudFront distribution has
index.htmlset as the default root object. -
If you need directory browsing behavior (like having
/among-us/automatically serve the index.html in that folder), you'll need to add a CloudFront Function to append index.html to directory paths.
If you absolutely need to use S3 website hosting features (like default index documents for subdirectories), you would need to make your bucket publicly accessible and use the website endpoint as a custom origin, but this is less secure than using OAI/OAC with a private bucket.
Sources
Access Denied for CloudFront to S3 static site | AWS re:Post
S3/Cloudfront & OAC: Access denied when accessing path other than index site | AWS re:Post
HTTP 403 status code (Permission Denied) - Amazon CloudFront
answered a year ago
