Aws lambda manages 2 status code for no errors event

I’m studying AWS. At the moment I understood how to manage APIGateway to solve correct status code errors.

Now I would like to return 2 different “positive” status code (200 and 202 depending by lambda logic..)

I know that mapping 200 without regex it will be the default one with no error, but I would like also to serve a 202 status code..

I’ve tried to raise an exception for 202 but if I implement the code that will match regex I can’t give back also my response
and viceversa if I use “mapping template” I don’t know how catch my data back.

I’m sure that is a logic mistake but I didn’t understand well yet:

  • How to trigger ApiGateway injecting also my Response?
  • Is it the right way to use an exception to switch “positive” status
    code (cause like this I’ll have a “wrong” exception event into the

(into comment the code/APIGateway cofiguration)


I’ve solved this problem raise the response object into the exception, and using a key of this to trigger the Lambda Error Regex for the correct status code.
I don’t know if is the right way but it works