Question

Difficulty: MediumAPI Development and Integration with Amazon API Gateway

A developer is migrating an Amazon API Gateway REST API from a Lambda custom (non-proxy) integration to a Lambda proxy integration. The API endpoint handles user profile updates and accepts query string parameters. Which TWO changes must the developer make to ensure the backend Lambda function and API Gateway integration function correctly after this migration?

  1. Modify the Lambda function's return statement to output a JSON object containing the status code, headers, and body.Answer
  2. Update the Lambda function code to retrieve query parameters from the structured properties under the event object instead of root-level keys.Answer
  3. C
    Configure integration response mapping templates in API Gateway to map the backend response to the client response.
  4. D
    Configure method response headers and HTTP status codes in API Gateway to match the statuses returned by the Lambda function.
  5. E
    Deploy a custom Lambda authorizer to validate Cognito JSON Web Tokens instead of using the built-in Cognito user pool authorizer.

Answer

The developer must modify the Lambda function's return statement to output a JSON object containing the status code, headers, and body, and update the Lambda function code to retrieve query parameters from the structured properties under the event object instead of root-level keys.
Migrating to a Lambda proxy integration simplifies configuration because API Gateway automatically forwards the raw request and response. The developer must update the Lambda function to return a structured JSON object containing the status code, headers, and body, and retrieve client request parameters from structured paths like event.queryStringParameters instead of root-level keys.

Step-by-Step Solution

1
Determine the output format requirements for Lambda proxy integrations.
Identify that the Lambda function must return a JSON object with statusCode, headers, and body.
Unlike custom integrations where API Gateway handles response mapping, proxy integrations require the backend to construct the raw response.
2
Determine the input format requirements for Lambda proxy integrations.
Understand that the raw request is passed directly as the event object, so query parameters must be accessed via structured keys like event.queryStringParameters.
Proxy integrations bypass input mapping templates, which changes how variables are parsed from the event object.
3
Eliminate configurations that are bypassed or unnecessary in proxy integrations.
Discard options suggesting the setup of API Gateway integration responses, method responses, or redundant custom authorizers.
Proxy integrations delegate response handling to the backend, rendering integration/method response mappings obsolete.

Key Concept

Understanding the difference in input/output payload structures and configuration requirements between API Gateway Lambda Proxy and Custom integrations.
Rate this question