GarlicBread
GarlicBread

Reputation: 1999

Serverless framework/Cloudformation: deploying Kinesis trigger with DLQ

I'm trying to deploy a lambda on AWS with Serverless which has a Kinesis data stream as a trigger. I'm also wanting to define that any failed messages raised by the lambda are sent to a Dead Letter queue.

I couldn't find an example of how to do this in the Serverless documentation, but I found what I thought was how to do it at https://betterdev.blog/aws-lambda-kinesis-trigger-pitfalls/.

I have created a Serverless file where the lambda target looks like this:

my_lambda:
    handler: src/lambdas/my_lambda.lambda_handler
    name: my_lambda
    memorySize: 256
    timeout: 28
    package:
        patterns:
          - 'src/lambdas/my_lambda.py'
    role: MyLambdaRole # Defined in a separate file.
    events:
        - stream:
            type: kinesis
            arn: ${self:custom.MY_KINESIS_DATA_STREAM_ARN} # ARN of Kinesis data stream.
            batchSize: 100
            maximumRetryAttempts: 10
            startingPosition: LATEST
            enabled: false
            destinations:
                onFailure:
                    type: sqs
                    arn: ${self:custom.MY_DLQ_ARN} # ARN of SQS DLQ.
    environment:
        ....
    tags:
        ....

When I try and deploy, I get this error:

TypeError: Cannot read property 'replace' of undefined
  at Object.normalizeNameToAlphaNumericOnly (/usr/local/lib/node_modules/serverless/lib/plugins/aws/lib/naming.js:32:36)
  at Object.getStreamLogicalId (/usr/local/lib/node_modules/serverless/lib/plugins/aws/lib/naming.js:372:14)
  at functionObj.events.forEach (/usr/local/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/stream.js:184:58)
  at Array.forEach (<anonymous>)
  at serverless.service.getAllFunctions.forEach (/usr/local/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/stream.js:143:28)
  at Array.forEach (<anonymous>)
  at AwsCompileStreamEvents.compileStreamEvents (/usr/local/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/stream.js:93:47)
  at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:579:20)

The message isn't helpful in identifying what the issue is. Could anyone suggest what the problem might be, please?

Thank you in advance for any assistance.

Upvotes: 0

Views: 370

Answers (1)

GarlicBread
GarlicBread

Reputation: 1999

Fixed: my Kinesis data stream ARN was incorrect.

Upvotes: 0

Related Questions