Q50 — AWS DVA-C02 Ch.1
Question 50 of 100 | ← Chapter 1
A developer created a static website and deployed its static assets to an Amazon S3 bucket, using Amazon CloudFront to serve those assets. The developer configured an Origin Access Control (OAC) on the CloudFront distribution to access the S3 bucket. The developer observes that users can access the root URL and specific pages, but cannot access directories without specifying a filename—for example, /products/index.html works, but /products/ returns an error. The developer wants to enable directory access without specifying filenames while keeping the S3 bucket private. Which solution meets these requirements?
- A. Update the CloudFront distribution settings to set index.html as the default root object.
- B. Update the Amazon S3 bucket settings and enable static website hosting. Specify index.html as the index document. Update the S3 bucket policy to allow access. Update the CloudFront distribution origin to use the S3 website endpoint.
- C. Create a CloudFront Function that checks the request URL and appends index.html when accessing a directory. Attach this function as a viewer request CloudFront Function to the CloudFront distribution behavior. ✓
- D. Create a custom error response on the CloudFront distribution, setting the HTTP error code to HTTP 404 Not Found response code, the response page path to /index.html, and the HTTP response code to HTTP 200 OK.
Correct Answer: C. Create a CloudFront Function that checks the request URL and appends index.html when accessing a directory. Attach this function as a viewer request CloudFront Function to the CloudFront distribution behavior.
Explanation
The developer should create a CloudFront Function to inspect the request URL and append index.html when accessing a directory. Then attach this function as a viewer request CloudFront Function to the CloudFront distribution behavior. This ensures that when users access a directory, CloudFront automatically appends index.html, enabling access to the default file within that directory. 【Lantern Certification provided by: swufelp1999】