A developer is configuring a new API endpoint using Amazon API Gateway that integrates with a backend AWS Lambda function using a Lambda proxy integration. Which two requirements must be met to ensure that client requests are correctly processed and the API returns valid responses? (Select TWO.)
- The Lambda function must return a JSON payload containing the 'statusCode', 'headers', and 'body' fields to API Gateway.Answer
- API Gateway automatically formats the client request details into a single JSON object and passes it to the Lambda function.Answer
- CThe developer must write Velocity Template Language (VTL) mapping templates in API Gateway to map the client request payload to the Lambda function.
- DThe backend Lambda function must programmatically invoke a Cognito User Pool token endpoint to validate incoming client identity tokens.
- EThe developer only needs to enable Cross-Origin Resource Sharing (CORS) on the API Gateway resource, as API Gateway automatically adds the required CORS headers to the Lambda proxy response.
Answer
The Lambda function must return a JSON payload containing the 'statusCode', 'headers', and 'body' fields to API Gateway, and API Gateway automatically formats the client request details into a single JSON object and passes it to the Lambda function.
With Lambda proxy integration, API Gateway automatically packages the incoming HTTP request details (headers, query parameters, stage variables, path parameters, and request body) into a single JSON object and passes it as the event payload to the backend Lambda function. In return, the Lambda function must return a JSON response structured with 'statusCode', 'headers', and 'body' fields so that API Gateway can map them to the corresponding client HTTP response.
Step-by-Step Solution
Key Concept
API Gateway Lambda Proxy Integration Requirements