exam questions

Exam AWS Certified Developer Associate All Questions

View all questions & answers for the AWS Certified Developer Associate exam

Exam AWS Certified Developer Associate topic 1 question 57 discussion

Exam question from Amazon's AWS Certified Developer Associate
Question #: 57
Topic #: 1
[All AWS Certified Developer Associate Questions]

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?

  • 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.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
amrElHusseiny
Highly Voted 3 years, 2 months ago
Selected Answer: B
i vote B With the Lambda proxy integration, Lambda is required to return an output of the following format ... In this output, statusCode is typically 4XX for a client error and 5XX for a server error. API Gateway handles these errors by mapping the Lambda error to an HTTP error response, according to the specified statusCode. For API Gateway to pass the error type (for example, InvalidParameterException), as part of the response to the client, the Lambda function must include a header (for example, "X-Amzn-ErrorType":"InvalidParameterException") in the headers property.
upvoted 16 times
...
claudiadlr
Highly Voted 3 years, 3 months ago
I'll go with "D" - https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html
upvoted 8 times
netk
3 years, 2 months ago
I think I'd go for B, since this is an standard error (4xx).
upvoted 1 times
...
dduenas
3 years, 3 months ago
In this link the correct answer would be "B" since it is talking about the error code not the error type
upvoted 3 times
...
...
sumanshu
Most Recent 4 months, 1 week ago
Selected Answer: B
B) Correct With Lambda proxy integration enabled, the Lambda function must return a JSON object with the following structure: { "statusCode": 400, "headers": { "Content-Type": "application/json" }, "body": "{\"message\": \"Invalid request\"}" } If the statusCode is omitted or incorrectly set, API Gateway defaults to returning a 200 status code.
upvoted 2 times
sumanshu
4 months, 1 week ago
A) Eliminated - Enabling CORS (Cross-Origin Resource Sharing) only allows cross-domain requests. It does not impact the HTTP status code returned.
upvoted 1 times
sumanshu
4 months, 1 week ago
D) Eliminated - The x-Amzn-ErrorType header is used by AWS to indicate internal error details. It is not the correct way to set the HTTP response status code.
upvoted 1 times
...
...
...
SD_CS
1 year, 2 months ago
Selected Answer: B
Lambda proxy integration can return the correct error message. A can not be the answer as CORS is not involved in a direct call
upvoted 1 times
...
OtavioC
2 years ago
Selected Answer: B
Answer is B, see on this link: https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html "With the Lambda proxy integration, Lambda is required to return an output of the following format:"
upvoted 1 times
...
Dominicwild12
2 years, 2 months ago
Selected Answer: B
B. Use a Lambda proxy integration to return HTTP codes and headers. When using a Lambda proxy integration, the Lambda function can return an HTTP status code and headers directly to the API Gateway, which then passes it on to the client. This is in contrast to a standard integration, where the Lambda function returns only the body of the response, and the API Gateway itself handles the HTTP status code and headers. Therefore, using a Lambda proxy integration can help resolve this issue and ensure that the appropriate HTTP status code is returned through the API Gateway.
upvoted 2 times
...
GD_ZH
2 years, 2 months ago
B should be the answer.
upvoted 1 times
...
Sidhusaab
2 years, 2 months ago
4xx is client side error, hence CORS
upvoted 2 times
...
wps
2 years, 5 months ago
Selected Answer: B
B correct
upvoted 2 times
...
haazybanj
2 years, 6 months ago
Selected Answer: B
Answer is B https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html
upvoted 2 times
...
warriorYup
2 years, 7 months ago
Selected Answer: B
https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html
upvoted 2 times
...
cloudbusting
2 years, 11 months ago
This is B https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html
upvoted 1 times
...
Rmnvcc
3 years, 3 months ago
"For Lambda custom integrations, you must map errors returned by Lambda in the integration response to standard HTTP error responses for your clients. Otherwise, Lambda errors are returned as 200 OK responses by default and the result is not intuitive for your API users." https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html
upvoted 3 times
CollinsWolf
2 years, 5 months ago
This is for customs and not proxy. They are two different solutions
upvoted 1 times
...
...
CHRIS12722222
3 years, 3 months ago
B. https://stackoverflow.com/questions/31329495/is-there-a-way-to-change-the-http-status-codes-returned-by-amazon-api-gateway
upvoted 4 times
...
striver
3 years, 3 months ago
D is the correct answer
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago