A developer is building a REST API using Amazon API Gateway that integrates with an existing AWS Lambda function. The Lambda function expects a JSON payload containing specific keys: `searchCategory` and `maxResults`. However, client applications will send requests containing query string parameters `category` and `limit` (for example, `/items?category=books&limit=10`). The developer wants API Gateway to transform these incoming query string parameters into the required JSON payload structure before invoking the Lambda function.
Which integration approach should the developer implement to meet these requirements?
- AConfigure a Lambda proxy integration and define a request mapping template to transform the query string parameters before passing them to the Lambda function.
- Configure a Lambda custom integration and define a request mapping template in API Gateway to map the query string parameters to the required JSON format.Cevap
- CConfigure a Lambda proxy integration and configure stage variables to rewrite the query parameters into the Lambda event object.
- DConfigure a Lambda authorizer to intercept the request, transform the query parameters, and inject the mapped JSON payload into the request context.
Cevap
Configure a Lambda custom integration and define a request mapping template in API Gateway to map the query string parameters to the required JSON format.
Configuring a Lambda custom integration (non-proxy integration) allows the developer to define an Integration Request mapping template. This template uses Velocity Template Language (VTL) to transform the incoming HTTP request query string parameters into the structured JSON payload format expected by the Lambda function before invocation.
Adım Adım Çözüm
Anahtar Kavram
API Gateway Lambda Custom vs. Proxy Integration