I'm currently hosting a static web site on AWS from an S3 bucket with a custom domain over TLS via CloudFront. AWS recently introduced Origin Access Control (OAC), which supposedly is a safer way to keep my S3 bucket private but still allow CloudFront to pull content from it for distribution.
But the OAC documentation for S3 seems to say that I have to disable the S3 website options to get OAC to work. I'm trying to understand the implications of this, because it's not spelled out. This is what I'm inferring:
- With OAC I can have content statically served from S3 over TLS using CloudFront; but
- the site can no longer be configured to automatically serve a default file; e.g. serving
https://example.com/index.htmlwhen the browser requestshttps://example.com/; and - I can no longer add server response redirects e.g. from
https://example.com/old.htmltohttps://example.com/new.html.
Is that a correct interpretation? Is there any other functionality I'll lose if I switch to OAC? Are there any workarounds when using OAC to get this functionality back?
Update: It appears that I can set a "default root object" of e.g. index.html via the CloudFormation distribution configuration. But it doesn't appear to be exactly the same as an S3 bucket website endpoint "index document" setting. For example, from the documentation it seems that this would serve https://example.com/index.html for https://example.com/, but would not serve https://example.com/foo/index.html for https://example.com/foo/, unless I'm misinterpreting what "the root URL for your distribution" means. Update: Verified that this is indeed the case. It may be possible to work around this using Lambda@Edge. I'll investigate further.
base/page1tobase/page2it throws anAccess Deniederror. So OAC not good for static site hosting for now, I guess.