A developer is transitioning an Amazon API Gateway REST API from a Lambda custom (non-proxy) integration to a Lambda proxy integration. The backend Lambda function needs to access the client's IP address and a query string parameter named `version` that were previously mapped via a Velocity Template Language (VTL) mapping template. The Lambda function also must return a custom HTTP status code of `201 Created` along with a JSON payload.
Which TWO actions must the developer take to accomplish this transition successfully? (Select TWO.)
- Access the client's IP address from `event.requestContext.identity.sourceIp` and the query string parameter from `event.queryStringParameters.version` in the Lambda input event.Cevap
- Update the Lambda function's return object to include a `statusCode` key with a value of `201` and a stringified JSON payload in the `body` key.Cevap
- CConfigure an Integration Request mapping template in API Gateway to extract the IP address via `$context.identity.sourceIp` and pass it to the Lambda function.
- DConfigure an Integration Response mapping template in API Gateway to map the custom JSON response keys to the HTTP `201` status code.
- EDeploy a Lambda Authorizer to validate the query string parameters and return the client's IP address inside the authorization context.
Cevap
Access the client's IP address from the request context and the query string parameter from the query string parameters block in the Lambda input event, and update the Lambda function's return object to include a statusCode of 201 and a stringified JSON payload in the body.
In a Lambda proxy integration, Amazon API Gateway automatically maps the client request into a standard JSON event structure and passes it directly to the Lambda function. The developer can access the client's IP address from `event.requestContext.identity.sourceIp` and the query string parameter from `event.queryStringParameters.version`. Furthermore, the Lambda function is responsible for returning a response formatted according to the proxy integration contract, which requires an object containing a `statusCode` (such as `201`) and a stringified JSON payload in the `body` field.
Adım Adım Çözüm
Anahtar Kavram
Understanding the input and output payload contract for AWS Lambda Proxy integrations versus Custom integrations in Amazon API Gateway.