Which solution will meet these requirements?
Update the CloudFront distribution’s settings to index.html as the default root object is set.
Update the Amazon S3 bucket settings and enable static website hosting. Specify index.html as the Index document. Update the S3 bucket policy to enable access. Update the CloudFront distribution’s origin to use the S3 website endpoint.
Create a CloudFront function that examines the request URL and appends index.html when directories are being accessed. Add the function as a viewer request CloudFront function to the CloudFront distribution’s behavior.
Create a custom error response on the CloudFront distribution with the HTTP error code set to the HTTP 404 Not Found response code and the response page path to /index.html. Set the HTTP response code to the HTTP 200 OK response code.
Explanations:
Settingindex.htmlas the default root object in CloudFront only helps with root requests. It does not resolve the issue of directory access without specifying a file.
Enabling static website hosting on S3 and using the S3 website endpoint is unnecessary for serving static assets with CloudFront. This option exposes the S3 bucket publicly, which the requirement specifically asks to avoid.
A CloudFront function can modify the request URL to appendindex.htmlwhen a directory is accessed, resolving the issue without exposing the S3 bucket.
A custom error response for HTTP 404 does not solve the issue of missingindex.htmlin directories. This option would only redirect failed requests, not solve the underlying directory access issue.