Event generating cloudwatch logs but not triggering lambda

0

New to aws, wrote a few lambda functions a few months ago that are triggered via external events sent to aws. Those are working fine. However, I created a few others in the past few days to accept other types of events. I get the cloudwatch logs but the lambda function does not appear to get executed.

1回答
3
承認された回答

I assume you are trying to invoke lambda function through cloudwatch events. If so, then did you check, if resource permission has been added to lambda function for that newly created rule. Most of the cases, this gets missed and even if event would match, it won't be able to invoke lambda function.

For your reference, here is the cloudformation snippet, how you'd add lambda resource permissions for the event rule:

 rLambdaInvokePermission:
      Type: 'AWS::Lambda::Permission'
      Properties:
        FunctionName: !Ref myLambdaFunction
        Action: 'lambda:InvokeFunction'
        Principal: events.amazonaws.com
        SourceArn: !GetAtt rEventRule.Arn

Second thing, I'd check, if event pattern is matching exactly what's defined in event rule or not. You can do that by testing the event rule pattern and see if it matches or not.

Also, I'd suggest you to take a look at this re:Post thread, which talks in details about the same topic.

Hoe you find this information helpful.

Comment here if you have additional questions, happy to help.

Abhishek

profile pictureAWS
エキスパート
回答済み 9ヶ月前
profile picture
エキスパート
レビュー済み 1ヶ月前
  • I did it via the console/UI in Amazon EventBridge bus from an outside source and a rule with 2 targets, a lambda and a cloudwatch event log group. Before getting your post, I decided to delete everything: lambda/rule/log groups and start from scratch. Somehow seems to be working now which is great but unfortunately I have no idea what made it work. Below is the cloudformation snipet of in my eventbridge rule. I do no see anything for LambdaInvokePermission. Perhaps your snippet is applicable for a different type of event source?

    AWSTemplateFormatVersion: '2010-09-09'
    Description: CloudFormation template for EventBridge rule 'scanner_v2'
    Resources:
      EventRule0:
        Type: AWS::Events::Rule
        Properties:
          Description:  scanner
          EventBusName: aws.partner/0.com/mdgdev/mdgdev
          EventPattern:
            detail-type:
              - v2-beta.automationFileTransform.updated.status
            detail:
              transform:
                customTransformId:
                  - app_xdooyCH7FU3Wjhq
                status:
                  - RUNNING
          Name: scanner_v2
          State: ENABLED
          Targets:
            - Id: Id6f8f1e72-97fc-4b93-8752-d6f964807f9
              Arn: arn:aws:lambda:us-east-1:05785795513:function:scanner_v2
            - Id: Id704a5cef-e352-4ca4-a780-b5e7cc95bb1
              Arn: >-
                arn:aws:logs:us-east-1:0578555913:log-group:/aws/events/scanner_v2_log_only
    
  • I'm glad you got it worked out.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ