简体   繁体   English

如何在CloudWatch Schedule + SQS上触发AWS Lambda

[英]How to trigger AWS Lambda on CloudWatch schedule + SQS

I know that AWS Lambda can be invoked by CloudWatch scheduler as well as by SQS event, but can they be used together in logical " and " combination? 我知道CloudWatch调度程序以及SQS事件都可以调用AWS Lambda,但是可以将它们以逻辑“ ”组合在一起使用吗?

Basically, what I need is to run my lambda every minute (for example) only when messages available in SQS . 基本上,我需要的是仅在SQS中有可用消息时每分钟运行一次lambda(例如)。 Is it even possible with AWS config only? 仅使用AWS config甚至有可能吗?

I need this to be able to utilize some third-party API with hard API limit, that's why I cannot just use SQS event (easy to break the limit) and I don't like the idea to use scheduler only, because it will be useless when queue is empty. 我需要此功能,以便能够使用具有严格API限制的某些第三方API,这就是为什么我不能仅使用SQS事件(容易打破限制)并且我不喜欢仅使用调度程序的想法,因为队列为空时无用。

While this is a cool idea, this is unfortunately not possible - event sources in Lambda are always separate from each other. 尽管这是一个很酷的主意,但不幸的是这是不可能的-Lambda中的事件源始终彼此分开。 I understand your impulse to save CPU-cycles and API-calls (and money), but I think the only solution that works is your proposed put-it-on-a-timer-and-poll-sqs one. 我了解您为节省CPU周期和API调用(以及节省金钱)的冲动,但是我认为唯一可行的解​​决方案是您建议的“将其放在计时器和投票中”的方法。

I was searching the documentation for references on this, but couldn't find any. 我正在搜索文档中有关此内容的参考,但找不到任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM