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

A developer hosts a static website on Amazon S3 and connects the website to an Amazon CloudFront distribution. The website uses a custom domain name that points to the CloudFront URL.

The developer has set up a continuous integration and continuous delivery (CI/CD) pipeline. The pipeline automatically runs when changes occur in an AWS CodeCommit repository. The pipeline has a source stage and then a build stage. The build stage invokes an AWS CodeBuild project that references a buildspec.yml file. The buildspec.yml file builds the code and deploys the static files to the S3 bucket.

The pipeline runs successfully, and the latest website files are visible in the S3 bucket and at the S3 website URL. However, when the developer accesses the website through the CloudFront domain, the updates are not reflected on the website.

What should the developer configure the buildspec.yml file to do to resolve this issue?

Answer options

Correct answer: C

Explanation

Amazon CloudFront caches content at edge locations to improve latency, which prevents it from immediately serving newly uploaded S3 files. By adding a command to invalidate the CloudFront cache in the buildspec.yml file, the developer forces CloudFront to fetch the latest files from the S3 origin. Options A and B are incorrect because the files are already successfully updated in S3, and modifying the CORS policy (Option D) addresses access permissions rather than caching issues.