Soru

Zorluk: OrtaAPI Development and Integration with Amazon API Gateway

A developer is configuring a REST API in Amazon API Gateway that integrates with a backend AWS Lambda function. The API currently uses a Lambda proxy integration. The developer wants to modify the structure of the incoming client JSON payload before it is passed to the backend Lambda function. The developer attempts to configure a mapping template in API Gateway but finds that it has no effect on the payload received by the Lambda function. Which of the following actions should the developer take to resolve this issue?

  1. Change the integration type to a Lambda custom integration, and define an integration request mapping template in API Gateway to transform the payload.Cevap
  2. B
    Keep the Lambda proxy integration, and configure a mapping template in the Integration Request section of API Gateway to transform the payload.
  3. C
    Implement a custom Lambda authorizer to intercept the incoming request, modify its structure, and pass the updated payload to the integration.
  4. D
    Keep the Lambda proxy integration, configure an API Gateway Model, and map the properties directly within the Method Request configuration.

Cevap

Change the integration type to a Lambda custom integration, and define an integration request mapping template in API Gateway to transform the payload.
The correct action is to change the integration type to a Lambda custom integration. In Amazon API Gateway, a Lambda proxy integration passes the raw request directly to the backend function without processing mapping templates. To utilize API Gateway's native request transformation capabilities, such as defining Velocity Template Language (VTL) mapping templates in the Integration Request, a Lambda custom integration must be used.

Adım Adım Çözüm

1
Analyze the integration type configuration.
Identify that the API is using a Lambda proxy integration.
Lambda proxy integration bypasses API Gateway request and response mapping templates entirely, forwarding the raw request structure directly to Lambda.
2
Determine the requirement for payload transformation.
Realize that transformation needs to happen at the API Gateway layer before reaching the backend.
To modify the payload structure before it hits the backend Lambda function, mapping templates must be evaluated by API Gateway.
3
Select the correct integration and mapping configuration.
Change the integration to a Lambda custom integration and configure the VTL mapping template.
Only Lambda custom (non-proxy) integrations support using Velocity Template Language (VTL) mapping templates to transform client request payloads.

Anahtar Kavram

API Gateway Lambda Custom vs Proxy Integration request mapping capabilities
Tahmini Süre:1m 30s
Bu soruyu puanla