An e-commerce company is migrating their legacy billing system to a serverless architecture. They choose to expose their backend AWS Lambda function using an Amazon API Gateway REST API with a Lambda proxy integration. To ensure that the client application receives a valid JSON response from the API, what specific output requirements must the Lambda function adhere to? (Select TWO.)
- Return a JSON object containing the 'statusCode' key set to an HTTP status code integer.Answer
- BDefine a response mapping template within the Integration Response in the API Gateway console.
- Return a JSON object containing the 'body' key set to a string representation of the JSON payload.Answer
- DConfigure a Lambda authorizer to process and format the return message from the Lambda function.
- EReturn only the business data payload as a raw JSON object, allowing API Gateway to default to a 200 status.
Answer
The Lambda function must return a JSON object containing a 'statusCode' key with the HTTP status code and a 'body' key with the stringified JSON payload.
In Amazon API Gateway Lambda proxy integrations, the backend AWS Lambda function is responsible for formatting the entire HTTP response. The response returned by the function must be a JSON object containing the 'statusCode' key (specifying the HTTP response code) and the 'body' key (containing a serialized string representation of the JSON payload).
Step-by-Step Solution
Key Concept
API Gateway Lambda Proxy Integration Response Format
Estimated Time:1m 0s