AWS Certified Developer – Associate — Question 48
A developer is debugging an AWS Lambda function behind an Amazon API Gateway. Whenever the API Gateway endpoint is called, HTTP status code 200 is returned even though AWS Lambda is recording a 4xx error.
What change needs to be made to return a proper error code through the API Gateway?
Answer options
- A. Enable CORS in the API Gateway method settings
- B. Use a Lambda proxy integration to return HTTP codes and headers
- C. Enable API Gateway error pass-through.
- D. Return the value in the header x-Amzn-ErrorType.
Correct answer: B
Explanation
The correct answer is B because using a Lambda proxy integration allows the Lambda function to return specific HTTP status codes and headers directly to the API Gateway, which can then relay the appropriate error codes to the client. The other options do not directly resolve the issue of returning accurate HTTP status codes from the Lambda function through the API Gateway.