每个方法的AWS API Gateway多个集成请求 [英] AWS API Gateway multiple Integration Request per Method

查看:81
本文介绍了每个方法的AWS API Gateway多个集成请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的资源/api具有方法POST,该方法将身体代理给Kinesis Firehose(然后代理给ES).同时,我希望它触发Lambda函数.

My resource /api has a method POST which proxies the body to Kinesis Firehose (and then to ES). At the same time I want it to trigger a Lambda function.

我尝试添加其他方法ANY来触发Lambda函数,但API Gateway似乎更喜欢POST处理程序.

I tried adding an additional method ANY to trigger the Lambda function but API Gateway seems to preference the POST handler.

我知道我可以在POST上触发Lambda并将Lambda函数提交给Firehose,但我更希望这两个彼此独立.

I am aware that I can trigger Lambda on POST and submit from the Lambda function to Firehose but I'd prefer having those two independent from each other.

推荐答案

API网关不会将请求派生到多个并发操作中. ANY 方法的意思是没有定义方法的任何方法".由于还定义了 POST ,因此任何 POST 都不会看到 ANY .

API Gateway doesn't fork a request into multiple concurrent actions. An ANY method means "any method without a defined method." Since you also have POST defined, any POST will not see the ANY.

要做您想做的事情-执行Lambda函数 并调用Kinesis API,您将需要编写一个初始的Lambda函数,该函数充当包装器并同时执行操作-向Kinesis发送请求并向Lambda发送请求(以调用另一个Lambda函数)-如果业务逻辑允许,则以异步方式发送-然后将结果编组为一个满足您需求的一致响应.

To do what you appear to be attempting -- execute a Lambda function and make a call to the Kinesis API, you will need to write an initial Lambda function that serves as a wrapper and performs both actions -- send a request to Kinesis and send a request to Lambda (to invoke the other Lambda function) -- asynchronously if the business logic permits it -- then marshal the results into a single coherent response that meets your needs.

第一个Lambda函数不需要与第二个Lambda函数使用相同的语言,因此,例如,如果现有的Lambda函数是用Java语言编写的,则包装函数可以用Node编写,而不会产生负面的性能影响,因为它可以在Lambda API的另一侧独立执行.

This first Lambda function does not need to be in the same language as the second, so for example, if the existing Lambda function is in Java, the wrapper function could be written in Node, with no negative performance implications, since it executes independently on the other side of the Lambda API.

这篇关于每个方法的AWS API Gateway多个集成请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆