A company is refactoring its web API backend. A developer configures an Amazon API Gateway REST API to use a Lambda proxy integration with an existing AWS Lambda function. During testing, clients receive 502 Bad Gateway errors. The CloudWatch logs show that the Lambda function completed its execution successfully without errors and returned the computed payload. Which action should the developer take to resolve the integration error?
- AConfigure an integration response mapping template in API Gateway to map the Lambda function's raw output to the client's expected JSON format.
- BUpdate the Lambda function's resource-based policy to grant the API Gateway execution role permission to assume the Lambda function's IAM execution role.
- Change the Lambda handler to return an object containing `statusCode` as an integer, `headers` as a map, and the serialized payload as a string under the `body` key.Cevap
- DConfigure a CORS policy in API Gateway to automatically inject the required response headers and strip the raw response wrapper.
Cevap
The correct action is to change the Lambda handler to return an object containing `statusCode` as an integer, `headers` as a map, and the serialized payload as a string under the `body` key.
The correct action is to change the Lambda handler to return an object containing `statusCode` as an integer, `headers` as a map, and the serialized payload as a string under the `body` key. In an API Gateway Lambda proxy integration, the backend Lambda function is entirely responsible for defining the HTTP response structure, which requires these specific fields.
Adım Adım Çözüm
Anahtar Kavram
API Gateway Lambda Proxy Integration Response Format