Api网关:用于Lambda集成的AWS子域 [英] Api Gateway: AWS Subdomain for Lambda Integration

查看:107
本文介绍了Api网关:用于Lambda集成的AWS子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的lambda函数与API网关集成,该函数必须运行异步,因为它花费的时间太长.我相信我必须选择"AWS服务"并指定Lambda,而不是选择"Lambda"集成类型. (例如似乎暗示这一点.)

I'm attempting to integrate my lambda function, which must run async because it takes too long, with API gateway. I believe I must, instead of choosing the "Lambda" integration type, choose "AWS Service" and specify Lambda. (e.g. this and this seem to imply that.)

但是,当我尝试将AWS Subdomain设置为Lambda函数的ARN时,会收到消息集成的AWS ARN必须包含路径或操作".如果将子域仅设置为Lambda函数的名称,则在尝试部署时会收到用于集成的AWS ARN包含无效路径"的信息.

However, I get the message "AWS ARN for integration must contain path or action" when I attempt to set the AWS Subdomain to the ARN of my Lambda function. If I set the subdomain to just the name of my Lambda function, when attempting to deploy I get "AWS ARN for integration contains invalid path".

对于这种类型的集成,正确的AWS子域是什么?

What is the proper AWS Subdomain for this type of integration?

请注意,我也可以采纳的建议并设置Kinesis流,但这对于我的简单用例来说似乎太过分了.如果那是解决我的问题的正确方法,请尝试尝试.

Note that I could also take the advice of this post and set up a Kinesis stream, but that seems excessive for my simple use case. If that's the proper way to resolve my problem, happy to try that.

随附的屏幕截图

有关不完整的解决方案,请参见下面的评论.

Please see comment below for an incomplete resolution.

推荐答案

因此设置起来很烦人,但这有两种方法:

So it's pretty annoying to set up, but here are two ways:

  1. 设置常规的Lambda集成,然后添加此处描述的InvocationType标头

  1. Set up a regular Lambda integration and then add the InvocationType header described here http://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html. The value should be 'Event'.

  • 这很烦人,因为在将Lambda函数作为Integration类型时,控制台不允许您添加标头.您必须使用SDK或CLI,或使用Swagger,您可以在其中轻松添加标头.

将整个内容设置为控制台中的AWS集成(这就是您要在问题中所做的事情),以便可以在控制台中设置InvocationType标头

Set the whole thing up as an AWS integration in the console (this is what you're doing in the question), just so you can set the InvocationType header in the console

  • 将子域留空
  • 使用路径替代"并将其设置为/2015-03-31/functions/<FunctionARN>/invocations,其中<FunctionARN>是lambda函数的完整ARN
  • HTTP方法是POST
  • 添加值为'Event'的静态标头X-Amz-Invocation-Type
  • Leave subdomain blank
  • "Use path override" and set it to /2015-03-31/functions/<FunctionARN>/invocations where <FunctionARN> is the full ARN of your lambda function
  • HTTP method is POST
  • Add a static header X-Amz-Invocation-Type with value 'Event'

http://docs.aws.amazon.com/lambda/Latest/dg/API_Invoke.html

这篇关于Api网关:用于Lambda集成的AWS子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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