A developer is building a serverless application using Amazon API Gateway and AWS Lambda. The application needs to access the client's source IP address and the incoming request headers within the Lambda function. The developer wants to achieve this with the least amount of operational effort and without writing manual mapping templates.
Which configuration should the developer choose for the API Gateway integration to meet these requirements?
- Configure a Lambda proxy integration for the API method.Answer
- BConfigure a Lambda custom integration and write a Velocity Template Language (VTL) mapping template to pass the request context parameters.
- CConfigure an Amazon Cognito User Pool authorizer to forward the request metadata in the authorization context.
- DConfigure a mock integration in API Gateway that maps the headers and source IP address into the integration request path parameters.
Answer
Configure a Lambda proxy integration for the API method.
Configuring a Lambda proxy integration is the most efficient approach because API Gateway automatically passes the entire raw request—including headers, query parameters, and the request context containing the client source IP—to the backend Lambda function as the input event object. This configuration requires no manual integration mapping templates, minimizing development and operational effort.
Step-by-Step Solution
Key Concept
API Gateway Lambda Proxy Integration
Estimated Time:1m 30s