Question #534
A company operates a content delivery platform hosted on-premises, serving various client devices including legacy systems that fail when encountering specific HTTP headers in responses. These legacy devices are identified by their User-Agent headers. The company uses a middleware component to strip these headers from responses directed to such devices. They aim to migrate the platform to AWS using serverless technologies while continuing support for legacy devices. The application backend has been transitioned to AWS Lambda functions.
Which solution fulfills these requirements?
Set up an Amazon CloudFront distribution for the content service. Create an Amazon API Gateway REST API. Configure CloudFront to route requests to the API Gateway. Set up the API Gateway to trigger the appropriate Lambda function for each request. Implement a CloudFront function to remove the problematic headers based on the User-Agent header.
Deploy an Amazon API Gateway HTTP API for the content service. Configure the API Gateway to invoke the corresponding Lambda functions. Develop a response mapping template in API Gateway to eliminate the problematic headers conditioned on the User-Agent header. Associate this template with the HTTP API.
Create an Amazon CloudFront distribution pointing to an Application Load Balancer (ALB). Configure the ALB to route to the Lambda functions. Use a Lambda@Edge function attached to the CloudFront distribution to strip the headers from responses when the User-Agent matches legacy devices.
Utilize Amazon API Gateway REST API for the content service, integrating it with the Lambda functions. Adjust the integration responses in API Gateway to remove the problematic headers dynamically by inspecting the User-Agent header from incoming requests.
Explanation
Answer A is correct because:
1. CloudFront Functions are lightweight, cost-effective, and execute at the edge, allowing immediate modification of HTTP headers in responses based on the User-Agent header from requests.
2. API Gateway integrates with Lambda for backend processing, while CloudFront handles routing and header manipulation, aligning with the serverless architecture.
Other options are incorrect because:
- B: HTTP APIs lack robust response mapping capabilities compared to REST APIs, and modifying headers conditionally via mapping templates is complex and less reliable.
- C: Lambda@Edge introduces unnecessary complexity and cost compared to CloudFront Functions, which are purpose-built for simple header manipulations.
- D: API Gateway integration responses cannot dynamically inspect the User-Agent header from requests to conditionally remove headers in responses.
Key Points: Use CloudFront Functions for edge-level header manipulation based on request attributes (e.g., User-Agent) in serverless architectures.
Answer
The correct answer is: A