0

My application includes a few lambdas, LA, LB and LC. LA and LB are sitting behind of API gateway. Both of them need to call LC for each request from users. Should I call LC via aws-sdk lambda API? Or should I build a API gateway in front of LC to let LA and LB call it in a rest way? What is the main different? What other factors need to concern?

Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
  • Putting it behind API gateway will, help if you want to keep the implementation detail abstracted for `LA` and `LB`. It can be a Lambda today and something else tomorrow. But, if that is going to result in an overhead performance hit due to the need of user authn and authz (as its a API Gateway, user could also invoke it directly) then try considering calling directly. – Ramesh Aug 12 '20 at 12:07
  • But Lambda calling another lambda is an anti pattern https://serverlessfirst.com/call-lambda-function-from-another/ – Ramesh Aug 12 '20 at 12:08
  • More thoughts on https://stackoverflow.com/questions/31714788/can-an-aws-lambda-function-call-another – Ramesh Aug 12 '20 at 12:09
  • You should consider using step function to synchronize your functions or chain them using sns/sqs. – Marcin Aug 12 '20 at 12:42

1 Answers1

0

I would never recommend calling another lambda from a lambda function. Though I do not know the complete details of the solution you are engineering but, from the outset, LC sitting behind an API Gateway will not hurt you in any way. It may provide you further benefits down the line but I don't see how it can potentially hurt you.

If you are trying to orchestrate a longer running task then have a look at AWS Step functions. You can chain together multiple AWS Services for longer running processes using Step Functions.

Anss
  • 664
  • 2
  • 7
  • 23