te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - AWS SQS lambda trigger disabled automatically - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AWS SQS lambda trigger disabled automatically - Stack Overflow

programmeradmin4浏览0评论

I have created aws SQS with lambda trigger. The issue I facing, is when message is send from sqs the lambda trigger automatically disconnected and also no log is generated in cloudwatch (log stream is generated). Anyone have any idea?

I have created aws SQS with lambda trigger. The issue I facing, is when message is send from sqs the lambda trigger automatically disconnected and also no log is generated in cloudwatch (log stream is generated). Anyone have any idea?

Share Improve this question asked Oct 22, 2018 at 5:41 Vaibhav PatilVaibhav Patil 3,0135 gold badges16 silver badges23 bronze badges 5
  • Does AWS SQS have the permission to invoke your AWS Lambda? – MaiKaY Commented Oct 22, 2018 at 5:45
  • If you Enable it, then manually send a message to the SQS queue, what happens? – John Rotenstein Commented Oct 22, 2018 at 6:27
  • "the lambda trigger automatically disconnected" ...what does this mean? Disconnected, how, and evidenced by what? – Michael - sqlbot Commented Oct 22, 2018 at 9:16
  • 1 aah, resolved it, I had set condition in my trust relationship that cause to disable lambda trigger. – Vaibhav Patil Commented Oct 23, 2018 at 7:20
  • 3 @VaibhavPatil how did you figure out this condition? How did you disable this condition? – Daniela Commented Dec 1, 2020 at 19:09
Add a ment  | 

5 Answers 5

Reset to default 6

For SQS Lambda triggers,

Your Amazon SQS role must include the following permissions:

  1. lambda:CreateEventSourceMapping
  2. lambda:ListEventSourceMappings
  3. lambda:ListFunction

Your Lambda role must include the following permissions:

  1. sqs:ChangeMessageVisibility
  2. sqs:DeleteMessage
  3. sqs:GetQueueAttributes
  4. sqs:ReceiveMessage

Also Note,

  • Your queue and Lambda function must be in the same AWS Region.
  • FIFO queues don't support Lambda function triggers.
  • You can associate only one queue with one or more Lambda functions.

For logs, check if your lambda has below cloudwatch permissions for generating logs

  • logs:CreateLogGroup
  • logs:CreateLogStream
  • logs:PutLogEvents

I encountered this also. Ultimately the 'disabled' SQS/Lambda trigger seems like a symptom that could result from multiple root causes.

In my case it wasn't a permissions issue. The root cause was an issue with the 'event source mapping' that maps your SQS queue's 'EventSourceArn' to your Lambda function's 'FunctionArn'. I had deleted and recreated SQS queue with the same name. The result of this was the trigger being automatically disabled by AWS when the first SQS queue was deleted, but the mapping persisting in its 'disabled' state when the new queue was created.

The workaround here was just to manually delete the event source mapping. Once this was done, the 'disabled' trigger no longer persisted. There's a good answer/explanation on a related question here - https://stackoverflow./a/62392964/8577382

If your permissions are in place as explained by other solution here and it still doesn't work, this is what we found

Our SQS messages were encrypted via KMS keys which Lambda did not have access to , AWS marks it as disable out of box.

Following on from the @Oisín answer, for me this happened after I had deleted and recreated a queue that had a lambda function attached to it. On re-creation, the queue already had the lambda attached to it in a disabled state.

If you go the lambda's configuration page and the Triggers section you can delete the triggers. Then go back to your SQS Queue and the lambda reference should have disappeared. You can then re-attach it

I know this is an old question but I figure I'd share as a related experience.

I had a lambda deployed and working (with three SQS triggers established and enabled). I later re-deployed the same lambda but changed the VPC, subnets, security groups and KMS key.

This caused one of the lambda triggers to disable itself. I'm guessing that during the deployment there was a blip which caused some issues with the event source mapping and AWS auto disabled it. All I had to do was manually enable it and things started working again as normal.

I had three triggers setup for three different queues on the same lambda. Only one of them auto-disabled and it only happened in 2 out of 6 regions. This queue was the main queue getting most of the events and these two regions were the most used regions. So I have a feeling it was just because of the higher traffic and more invocations that caused a confusion.

Good thing my retention policy on the queue was long enough for me to spot the issue and fix it.

发布评论

评论列表(0)

  1. 暂无评论