Question

Difficulty: EasyServerless Development with AWS Lambda

A developer is building a serverless web API using Amazon API Gateway and AWS Lambda with a Lambda Proxy integration. Which two actions must the developer take to ensure the Lambda function correctly receives client requests and returns successful responses? (Select TWO.)

  1. Format the Lambda function's return object to contain the 'statusCode', 'headers', and 'body' properties.Answer
  2. Access incoming request details, such as query string parameters, directly from the 'event' input parameter of the Lambda handler.Answer
  3. C
    Configure API Gateway integration response mapping templates to format the JSON response structure.
  4. D
    Hardcode AWS IAM user credentials in the Lambda function code to authorize the integration between API Gateway and Lambda.
  5. E
    Deploy the Lambda function in a public VPC subnet with a public IP address to allow API Gateway to communicate with it.

Answer

The developer must format the Lambda function's return object to contain the 'statusCode', 'headers', and 'body' properties, and access incoming request details, such as query string parameters, directly from the 'event' input parameter of the Lambda handler.
For Lambda Proxy integrations, the Lambda function must return a response matching the expected JSON structure containing 'statusCode', 'headers', and 'body'. Additionally, all incoming request details (such as path parameters and query strings) are accessible via the 'event' parameter passed to the Lambda handler.

Step-by-Step Solution

1
Analyze the integration type between API Gateway and AWS Lambda.
The scenario specifies Lambda Proxy integration, which means API Gateway passes the raw request directly to Lambda and expects a specific output format from Lambda.
This determines how inputs are read and how outputs must be structured.
2
Determine how input parameters are read in the Lambda function.
The input parameters like query string parameters are mapped into the 'event' argument passed to the handler.
With Lambda Proxy integration, API Gateway automatically packages request details into the 'event' parameter.
3
Determine how the response is constructed by the Lambda function.
The function must return a JSON object with 'statusCode', 'headers', and 'body' keys.
Without this structure, API Gateway will throw a 502 Bad Gateway error as it cannot parse the response.

Key Concept

API Gateway Lambda Proxy Integration requirements
Rate this question