Api Gateway, parse a 429 Response

0

I have an API Gateway in front of a Lambda that has reserved concurrency. When the Lambda returns a 429 for throttling, I'd like to reply to the API client with a 429 Method Response. I have other Integration Responses working for other Method Responses, based on the Lambda's response body. However, I can't get the integration response to process the response body like it does with other responses; perhaps because those responses are http 200's, and this is a non-200?

Wed Jun 08 20:17:53 UTC 2022 : Endpoint response body before transformations:{"Reason":"ReservedFunctionConcurrentInvocationLimitExceeded","Type":"User","message":"Rate Exceeded."} Wed Jun 08 20:17:53 UTC 2022 : Lambda invocation failed with status: 429. Lambda request id: 00000000-e2b9-4000-9f00-700000007a

(I'd expect the mapping template to be able to parse the above json in the "Endpoint response body before transformations" message, like the other responses being handled, but nope...)

Wed Jun 08 20:17:53 UTC 2022 : Execution failed due to configuration error: Rate Exceeded.
Wed Jun 08 20:17:53 UTC 2022 : Method completed with status: 500

How can I parse the response body of a non-200 response?

1 Answer
0

Have you tried creating a Method Response of 429 first and then going back to the Integration Response and trying to map 429 in the Integration Response to 429 in the Method Response and keeping the content as Passthrough. What happens? Do you get back a 429 or a 500 in the response to the client?

profile pictureAWS
EXPERT
answered 2 years ago
  • I get the same experience whether trying to pass through, or trying to use a mapping templage.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions