Event Bridge Dead Letter Config

Hey there,
The serverless docs of Event Bridge here do not mention how to set up a dead letter queues and retry attempts. I was hoping the configuration would look something like below but it did not work.
Is there a way to add DLQ on a Lambda invoked by Event Bus?

myLambda:
    handler:  ./src/functions/destinationLambda/index.handler
    events:
      - eventBridge:
          eventBus: arn:aws:events:region:accountID:event-bus/busname
          deadLetterConfig: 
            arn: arn:aws:sqs:region:accountID:sqs-name
          pattern:
            source: 
              - ${self:custom.sourceNameForEventBus}
2 Likes

I need to do the same thing. I assume this isn’t supported since there has been zero activity/response to your question. :frowning:

Yeah, they are still trying to add this feature. In the end, I just wrote cloudformation in my serverless.yml to add Dead letter queue

Hello, I’m trying to do exactly the same thing, do you have any example of how you did by any chance?

Thanks in advance.

You can write something like this in your serverless.yml’s resources section,
Note: lambda:InvokeFunction is necessary permission to add

    CustomBusRule: 
        Type: AWS::Events::Rule
        Properties: 
            EventBusName: ${self:custom.eventBusName}
            EventPattern: 
                source: 
                    - my-source
            State: "ENABLED"
            Targets: 
            - 
                Arn: 
                    Fn::GetAtt: 
                        - "<lambdaName>LambdaFunction"
                        - "Arn"
                Id: "random"
                DeadLetterConfig:
                    Arn: ${self:custom.sqsARN}
    PermissionInvokeLambda: 
        Type: AWS::Lambda::Permission
        Properties: 
            FunctionName: !Ref "<lambdaName>LambdaFunction"
            Action: "lambda:InvokeFunction"
            Principal: "events.amazonaws.com"
            SourceArn: 
                Fn::GetAtt: 
                    - "CustomBusRule"
                    - "Arn"

Other option that I use is to call the api putTargets by writing a custom plugin