5

I'm looking a solution for my problem and maybe someone could give me some ideas. I have a API Gateway plugged to a aws lambda A. I have to handle cases like this:

  1. Lambda A should call lambda B and if there are any results, return to the API Gateway.
  2. Lambda A should call lambda B and if no results, it will call lambda C, and then return whatever the results are to the APi Gateway.

So, my problem is how to chain these lambdas, because I don't want to have a huge lambda. At first, I thought about using Step Functions except that this works in a asynchronous mode, so no good for my case. I know I can do a lambda to call the step function and wait for the result, but I don't like this solution.

Any ideas for a nice solution ?

Thanks.

C.C.

4

3 回答 3

3

您可以使用带有“异步等待”的调用 lambda,这是文档:

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property

对于异步调用: https ://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invokeAsync-property

于 2019-09-16T06:55:58.547 回答
0

您可以使用AWS Step Function管理 AWS lambda 函数之间的协调。

于 2018-02-27T17:57:50.793 回答
0

真的 B & C 是 A 调用的 api

使用 IAM auth 将 lambda B & C 放在另一个 api 网关后面。授予 A 通过您的 IAM 角色调用该 API 的权利。

  • 现在,您的外部客户通过任何身份验证方案调用 A。
  • A 可以通过 api 调用 B 或 C(可能是 url 作为参数)
  • A 可以将结果返回给调用者

对于更精细的方法,您可以将 B/C 作为它们自己的 api 网关,这意味着您已经将它们完全解耦

于 2018-05-22T10:23:43.157 回答