尽管有关于 lambda 的资源策略声明,EventBridge 规则不会触发 Lambda

发布于 2025-01-21 04:06:32 字数 1750 浏览 2 评论 0原文

我有一个无服务器文件,该文件在默认事件总线上创建了EventBridge规则:

    StepFunctionErrorEvent:
      Type: AWS::Events::Rule
      Properties:
        Name: ${self:custom.resourcePrefix}-step-function-error-event-rule
        Description: Event bus rule coordinating what targets receive Step Function error events
        EventPattern:
          source:
            - "aws.states"
          "detail-type":
            - "Step Functions Execution Status Change"
          detail:
            state:
              - "FAILED"
              - "TIMED_OUT"
              - "ABORTED"
        Targets:
          - Arn: ${cf:${self:custom.resourcePrefix}-service-internal-slack-integration.PostSlackMessageLambdaArn}
            Id: "ErrorSlackMessage"
            DeadLetterConfig:
              Arn: !GetAtt DefaultErrorTargetDLQ.Arn
    DefaultErrorTargetDLQ:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: ${self:custom.resourcePrefix}-DefaultErrorTargetDL

在一个单独的无服务器文件中,也将部署我将以下lambda权限添加到pl-us-us-east-2-pilot- slack-message

resources:
  Resources:
    TriggerPostSlackMessageLambda:
      Type: AWS::Lambda::Permission
      Properties:
        FunctionName: !GetAtt PostSlackMessageLambdaFunction.Arn
        Action: lambda:InvokeFunction
        Principal: events.amazonaws.com
        SourceArn: !Sub arn:aws:events:${AWS::Region}:${AWS::AccountId}:rule/pl-us-east-2-pilot-step-function-error-event-rule

然而,尽管pl-us-east-2-pilot-post-post-slack-message lambda在“基于资源的策略”下列出了上述许可(在lambda控制台)事件桥规则在发生lambda故障时不会触发。如果我使用AWS控制台创建一个新规则,它确实会触发,但是无论出于何种原因,它都无法成功使用无服务器/云形式触发。

我似乎读过的有关此主题的每篇文章都提到了同一件事 - 那就是在您的lambda上设置了许可,但是我已经做到了,但仍然无法正常工作。有人知道它没有触发的原因是什么?

I've got a serverless file which creates an eventbridge rule on the default event bus:

    StepFunctionErrorEvent:
      Type: AWS::Events::Rule
      Properties:
        Name: ${self:custom.resourcePrefix}-step-function-error-event-rule
        Description: Event bus rule coordinating what targets receive Step Function error events
        EventPattern:
          source:
            - "aws.states"
          "detail-type":
            - "Step Functions Execution Status Change"
          detail:
            state:
              - "FAILED"
              - "TIMED_OUT"
              - "ABORTED"
        Targets:
          - Arn: ${cf:${self:custom.resourcePrefix}-service-internal-slack-integration.PostSlackMessageLambdaArn}
            Id: "ErrorSlackMessage"
            DeadLetterConfig:
              Arn: !GetAtt DefaultErrorTargetDLQ.Arn
    DefaultErrorTargetDLQ:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: ${self:custom.resourcePrefix}-DefaultErrorTargetDL

And in a seperate serverless file which also gets deployed I'm adding the following Lambda permission to pl-us-east-2-pilot-post-slack-message:

resources:
  Resources:
    TriggerPostSlackMessageLambda:
      Type: AWS::Lambda::Permission
      Properties:
        FunctionName: !GetAtt PostSlackMessageLambdaFunction.Arn
        Action: lambda:InvokeFunction
        Principal: events.amazonaws.com
        SourceArn: !Sub arn:aws:events:${AWS::Region}:${AWS::AccountId}:rule/pl-us-east-2-pilot-step-function-error-event-rule

However despite pl-us-east-2-pilot-post-slack-message lambda having the above listed as a permission under 'Resource based policy' (in the Lambda console) the EventBridge rule does not trigger when there is a Lambda failure. It does trigger if I create a new rule using the AWS Console, but for whatever reason it's not able to successfully trigger using serverless/CloudFormation.

Every post I seem to read about this topic makes mention of the same thing - that is to have the permission set on your Lambda, but I've done that and it's still not working. Does anyone have any idea what could be the reason why it's not triggering?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你另情深 2025-01-28 04:06:32

很难发现,但是由于我使用步骤功能

          detail:
            state:
              - "FAILED"
              - "TIMED_OUT"
              - "ABORTED"

应该是

          detail:
            status:
              - "FAILED"
              - "TIMED_OUT"
              - "ABORTED"

hard one to spot, but since i was using step functions

          detail:
            state:
              - "FAILED"
              - "TIMED_OUT"
              - "ABORTED"

should be

          detail:
            status:
              - "FAILED"
              - "TIMED_OUT"
              - "ABORTED"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文