Soru

Zorluk: OrtaAPI Development and Integration with Amazon API Gateway

A developer is configuring a REST API in Amazon API Gateway to integrate with a backend AWS Lambda function. To minimize administrative overhead and avoid writing custom mapping templates, the developer decides to use a Lambda proxy integration. Which TWO requirements must be met to ensure this integration works correctly? (Select TWO.)

  1. The Lambda function must return a JSON object containing at least statusCode, headers, and a stringified body.Cevap
  2. API Gateway automatically passes the entire client request (including headers, query parameters, and body) as a single JSON object to the input event of the Lambda function.Cevap
  3. C
    The developer must define Integration Response mappings in API Gateway to map the Lambda output to specific HTTP status codes.
  4. D
    The developer must configure a custom Lambda authorizer to parse incoming query string parameters before passing them to the Lambda function.
  5. E
    The Lambda function must return a raw string containing the HTTP body, and API Gateway will automatically wrap it in a 200 OK status.

Cevap

The Lambda function must return a JSON object containing at least statusCode, headers, and a stringified body; and API Gateway automatically passes the entire client request (including headers, query parameters, and body) as a single JSON object to the input event of the Lambda function.
In a Lambda proxy integration, API Gateway passes the raw client request directly to the Lambda function as a single JSON event structure, removing the need for request mapping templates. On the response path, API Gateway expects the Lambda function to return a specific JSON format containing the status code, headers, and body. If the function returns a raw string or lacks the expected structure, API Gateway will throw a 502 Bad Gateway error.

Adım Adım Çözüm

1
Analyze the integration type selected by the developer, which is Lambda proxy integration.
Identify that Lambda proxy integration requires strict output formatting from the backend and passes the raw request directly to the backend without API Gateway mapping templates.
This establishes the core constraints of proxy integration vs. custom integration.
2
Evaluate how request data is passed from API Gateway to the backend Lambda function.
Determine that the entire HTTP request payload, including path parameters, query parameters, headers, and body, is mapped to the input event object automatically.
This validates the request-side requirements.
3
Evaluate the response contract required for Lambda proxy integration.
Determine that the Lambda function must return a specific JSON response containing fields such as statusCode, headers, and a stringified body, otherwise API Gateway will return a 502 Bad Gateway error.
This validates the response-side requirements.

Anahtar Kavram

Understanding request and response structure in API Gateway Lambda Proxy integration
Bu soruyu puanla