当从SQS触发时,AWS Lambda不会在失败条件下触发SNS通知。

huangapple go评论65阅读模式
英文:

When triggered from SQS, AWS Lambda does not trigger SNS notifications on failure condition

问题

I created AWS Lambda and set that is trigged when some SQS message appears. Lambda is triggered and let's say that fails. I wanted to setup "On failure" destination which triggers SNS topic where I would have Email subscription.

我创建了AWS Lambda,并设置了当出现某个SQS消息时触发它。Lambda被触发,假设它失败了。我想设置“失败时”目标,触发SNS主题,我在其中有电子邮件订阅。

I deliberately made lambda fail, I can see failure in Cloudwatch. However, I didn't received any email from SNS.

我故意让Lambda失败,我可以在Cloudwatch中看到失败。然而,我没有收到来自SNS的任何电子邮件。

To confirm everything actually works regarding SNS and Email subscription I setup S3 as additional trigger to lambda.
In this case, lambda is triggered, failed but I received email from SNS topic configured inside lambda. That means configuration is correct but something is different when source trigger for lambda is SQS rather than S3.

为了确认关于SNS和电子邮件订阅的一切都有效,我将S3设置为Lambda的附加触发器。在这种情况下,Lambda被触发,失败了,但我收到了Lambda内配置的SNS主题的电子邮件。这意味着配置是正确的,但当Lambda的触发源是SQS而不是S3时,有一些不同之处。

What I am missing? Why Lambda is not triggering SNS (or SNS not triggering notifications) when source for lambda is SQS and works perfectly when source is let's say S3?

我缺少什么?为什么当Lambda的触发源是SQS时,Lambda不触发SNS(或SNS不触发通知),而当触发源是S3时,一切都运行完美?

英文:

I created AWS Lambda and set that is trigged when some SQS message appears. Lambda is triggered and let's say that fails. I wanted to setup "On failure" destination which triggers SNS topic where I would have Email subscription.

I deliberately made lambda fail, I can see failure in Cloudwatch. However, I didn't received any email from SNS.

To confirm everything actually works regarding SNS and Email subscription I setup S3 as additional trigger to lambda.
In this case, lambda is triggered, failed but I received email from SNS topic configured inside lambda. That means configuration is correct but something is different when source trigger for lambda is SQS rather than S3.

What I am missing? Why Lambda is not triggering SNS (or SNS not triggering notifications) when source for lambda is SQS and works perfectly when source is let's say S3?

答案1

得分: 1

Lambda的onSuccess / onFailure目标仅支持异步调用1:S3会异步调用您的Lambda,而SQS会同步调用它。

如果您想保持当前的实现,您必须直接将SNS发布放在您的Lambda内部。

英文:

Lambda destinations onSuccess / onFailure are supported only for asynch invocations: S3 calls your Lambda asynchronously, SQS calls it synchronously instead.

If you want to mantain the current implementation, you have to put the SNS publish directly inside your Lambda.

huangapple
  • 本文由 发表于 2023年2月23日 21:53:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75545733.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定