A developer is configuring a REST API using Amazon API Gateway. The backend integrates with an AWS Lambda function using a Lambda custom (non-proxy) integration. The client sends a GET request to the API with a query string parameter named `version`. The developer wants the Lambda function to receive a JSON payload structured exactly as `{"apiVersion": "<version_value>"}` in its input event.
Which configuration must the developer implement in API Gateway to satisfy this requirement?
- Configure an Integration Request body mapping template for the application/json content type that maps the query parameter using $input.params('version') to the apiVersion key.Cevap
- BEnable Lambda proxy integration on the method and read the apiVersion key directly from the root of the event object in the Lambda function.
- CConfigure a custom Lambda authorizer to extract the version query parameter and return it as apiVersion inside the validation context to the Lambda function.
- DConfigure an Integration Response body mapping template in the API Gateway method settings to map the version query parameter to the apiVersion key.
Cevap
Configure an Integration Request body mapping template for the application/json content type that maps the query parameter using $input.params('version') to the apiVersion key.
In a Lambda custom (non-proxy) integration, API Gateway does not automatically pass the raw request structure to the backend. Instead, the developer must define a mapping template under the Integration Request settings to construct the JSON payload that the Lambda function receives. The $input.params() function is used in the VTL mapping template to extract query parameters, headers, or path variables, allowing the creation of the required structure.
Adım Adım Çözüm
Anahtar Kavram
API Gateway Integration Request Mapping Templates