Api网关:用于Lambda集成的AWS子域

编程入门 行业动态 更新时间:2024-10-21 20:40:41
本文介绍了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:

  • 设置常规的Lambda集成,然后添加此处描述的InvocationType标头 docs.aws.amazon/lambda/latest/dg/API_Invoke.html .该值应为事件".

  • Set up a regular Lambda integration and then add the InvocationType header described here docs.aws.amazon/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'

    docs.aws.amazon/lambda/Latest/dg/API_Invoke.html

  • 更多推荐

    Api网关:用于Lambda集成的AWS子域

    本文发布于:2023-11-24 04:29:04,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1623973.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:网关   Api   AWS   Lambda

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!