AWS Certified Solutions Architect – Professional — Question 882
A company has developed a single-page web application in JavaScript. The source code is stored in a single Amazon S3 bucket in the us-east-1 Region. The company serves the web application to a global user base through Amazon CloudFront.
The company wants to experiment with two versions of the website without informing application users. Each version of the website will reside in its own S3 bucket. The company wants to determine which version is most successful in marketing a new product.
The solution must send application users that are based in Europe to the new website design. The solution must send application users that are based in the
United States to the current website design. However, some exceptions exist. The company needs to be able to redirect specific users to the new website design, regardless of the users' location.
Which solution meets these requirements?
Answer options
- A. Configure two CloudFront distributions. Configure a geolocation routing policy in Amazon Route 53 to route traffic to the appropriate CloudFront endpoint based on the location of clients.
- B. Configure a single CloudFront distribution. Create a behavior with different paths for each version of the site. Configure Lambda@Edge on the default path to generate redirects and send the client to the correct version of the website.
- C. Configure a single CloudFront distribution. Configure an alternate domain name on the distribution. Configure two behaviors to route users to the different S3 origins based on the domain name that the client uses in the HTTP request.
- D. Configure a single CloudFront distribution with Lambda@Edge. Use Lambda@Edge to send user requests to different origins based on request attributes.
Correct answer: D
Explanation
Using a single CloudFront distribution with Lambda@Edge allows you to inspect incoming request attributes, such as the viewer's country header (CloudFront-Viewer-Country) and custom headers or cookies for specific user overrides. Based on these attributes, Lambda@Edge can dynamically alter the origin request to point to either the current or new S3 bucket without changing the URL or requiring multiple distributions. Other options like Route 53 geolocation routing cannot handle individual user overrides based on request attributes like cookies or query strings, and redirecting via paths would expose the change to the user.