AWS Certified Developer – Associate (DVA-C02) — Question 298

A developer creates a static website for their department. The developer deploys the static assets for the website to an Amazon S3 bucket and serves the assets with Amazon CloudFront. The developer uses origin access control (OAC) on the CloudFront distribution to access the S3 bucket.

The developer notices users can access the root URL and specific pages but cannot access directories without specifying a file name. For example, /products/index.html works, but /products/ returns an error. The developer needs to enable accessing directories without specifying a file name without exposing the S3 bucket publicly.

Which solution will meet these requirements?

Answer options

Correct answer: C

Explanation

CloudFront's default root object feature only works for the root URL, not for subdirectories. Using a CloudFront Function allows you to rewrite the request URL on the fly to append 'index.html' to subdirectory requests while maintaining S3 bucket privacy via Origin Access Control (OAC). Using the S3 website endpoint instead of OAC would require making the S3 bucket public, which violates the security requirement.