3

I've set up a function in AWS Lambda that acts as a request handler, receiving HTTP requests via AWS API Gateway.

I would like to keep this 'path' completely unmodified, but also have a second Lambda function to receive (duplicates of) all these requests. The responses of those second (parallel) function invocations could be neglected - the other Lambda function is the one that counts. (I would be interested in knowing the responses of both functions though.)

Reason for this requirements is that I want both functions to be executed (possibly in parallel, but that doesn't matter) and be able to compare the results of these two functions.

I can't figure out how to set up this in AWS Lambda (or in AWS API Gateway, which could have been possible as well).

In some web application frameworks like Express (JavaScript), Sinatra (Ruby) or Flask (Python) there are capabilities like resp. global request handlers, before_requests() and before() filters which are close to what I want to achieve.

How can this be done in AWS Lambda (and/or AWS API Gateway)?

Jochem Schulenklopper
  • 6,452
  • 4
  • 44
  • 62
  • 1
    It might be worth sharing more on why you want to duplicate the requests. One possibility is for Lambda A, when invoked, to simply perform an (async?) invocation of Lambda B, passing the same parameters to it. A better pattern, though possibly not appropriate here, would be for the original request to be sent as an SNS message and then for SNS to fan out to multiple Lambda subscribers. – jarmod Nov 30 '18 at 15:23
  • yes @jarmod is right it depends on your requirement please elobrate more – varnit Nov 30 '18 at 17:08
  • maybe you can use aws step functions for this https://aws.amazon.com/step-functions – ttulka Nov 30 '18 at 20:38
  • @jarmod, I just added the goal to the original question. – Jochem Schulenklopper Dec 01 '18 at 15:39
  • @jarmod, "One possibility is for Lambda A, when invoked, to simply perform an (async?) invocation of Lambda B, passing the same parameters to it." is indeed the implemented that I made now. Somehow I'm hoping that an alternative function can be introduced and invoked without changing anything in the 'original' Lambda function. Not sure if that'd work though, hence the question here. – Jochem Schulenklopper Dec 01 '18 at 15:40

0 Answers0