Question

Difficulty: MediumAPI Development and Integration with Amazon API Gateway

A developer is configuring a REST API in Amazon API Gateway that integrates with an AWS Lambda function. The Lambda function must access the client's source IP address, a query string parameter named `storeId`, and a custom HTTP header named `X-Client-Device` from incoming requests. The developer wants to implement this with minimal configuration overhead and without writing mapping templates. Which two actions must the developer take to meet these requirements? (Select TWO.)

  1. Configure the API Gateway integration type as Lambda Proxy Integration.Answer
  2. B
    Define a Velocity Template Language (VTL) mapping template in the Integration Request to pass parameters.
  3. C
    Create a custom Lambda Authorizer to extract the custom header and client IP and inject them into the request context.
  4. Access the client IP, query string parameter, and custom header directly from the event object inside the Lambda function code.Answer
  5. E
    Configure an API Gateway Integration Response mapping template to parse and format the return payload from the Lambda function.

Answer

The developer should configure the API Gateway integration type as Lambda Proxy Integration and access the client IP, query string parameter, and custom header directly from the event object inside the Lambda function code.
Configuring the API Gateway integration type as Lambda Proxy Integration is correct because it passes all request metadata—including query string parameters, headers, and client connection context—directly to the backend Lambda function. Accessing these parameters from the event object inside the Lambda function handler is correct because the proxy integration formats the request as a structured JSON object, allowing direct extraction of the data within the function code without writing any VTL mapping templates.

Step-by-Step Solution

1
Analyze API Gateway integration options to meet the minimal configuration and zero-mapping template requirements.
Lambda Proxy integration is selected because it forwards the raw HTTP request directly to the Lambda function without mapping templates.
Lambda Custom integration requires manually defining request mapping templates, which increases configuration overhead.
2
Determine how the backend Lambda function accesses the forwarded parameters under a proxy integration.
The parameters are read from the handler's event parameter: the IP from the requestContext object, the header from the headers object, and the query string from the queryStringParameters object.
Lambda Proxy integration structures the incoming request into a standard JSON event schema containing all request metadata.

Key Concept

API Gateway Lambda Proxy Integration vs Lambda Custom Integration
Estimated Time:1m 30s
Rate this question