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?

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】