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
전문가
검토됨 한 달 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠