尽管有关于 lambda 的资源策略声明,EventBridge 规则不会触发 Lambda
我有一个无服务器文件,该文件在默认事件总线上创建了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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很难发现,但是由于我使用步骤功能
应该是
hard one to spot, but since i was using step functions
should be