- Newest
- Most votes
- Most comments
This is just AWS Cloudfront working as designed, I just forgot about this detail.
I want to use the REST API endpoint for S3 obviously because I prefer having buckets without public access. But using the REST API endpoint of S3 means Cloudfront is unable to lookup index files in sub-directories. It can only lookup the default root object in root.
So the solution used to be to create a Lambda that would do the lookup for you, but now there are CF functions that should be simpler, so I'm going to try that.
The other workaround is of course to enable static website hosting on the bucket, use the S3 website endpoint, but that means I also need to open up my bucket for public access.
How long ago did you set the bucket up? I've seen this before and sometimes it's a matter of letting the S3 control plane replicate information globally. The way to tell is to look at the URL when you get the Access Denied
message. If you see the bucket URL and not CloudFront - just wait.
Because you've created the bucket in a region that isn't us-east-1
the S3 control plane (which is global) hasn't yet replicated the information that the bucket is in eu-north-1
so it uses a redirect to the browser to get you to the right place in the short term. But because of the bucket policy the browser access is rejected. It's temporary and only occurs if the bucket is quite new.
Edit to add detail from OP comment
You don't need to do anything special to use CloudFront to publish a non-public S3 bucket and still have access to sub-directories. Check out the documentation because it gives instructions on how to do exactly that. It's better than using Lambda@Edge because it is zero complexity and zero extra cost.
You can see the error yourself here: https://blog.mastodon.se/om/
It was setup about 12 hours ago, last evening.
Relevant content
- asked 5 months ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 6 months ago
Also static website hosting is http only - no https!