Home > Software engineering >  Is it possible to use AWS Step Functions to poll a DynamoDB Stream to reduce Lambda complexity?
Is it possible to use AWS Step Functions to poll a DynamoDB Stream to reduce Lambda complexity?

Time:02-15

I am planning to use a DynamoDB Stream to do a bunch of task on a very complex single table. The task include actions such as sending notifications, updating other entries in the database and indexing some entries using AWS OpenSearch. I can already see that the Lambda function to handle all of this will end up being massively complex and very hard to maintain. It also feels very wasteful since most actions that would be included in this lambda only apply to very specific stream events and are not required for most others.

My thought was that I could maybe use a StateMachine to split these task up into individual Lambdas and then only run them when they are needed for a certain item in the stream.

So I'm curious if there is any easy way to poll a DynamoDB Stream with a Step Function in the same way you would do with a Lambda.

(PS. I know this could be considered an opinion question, but I would also be curious about anyone's thoughts on this solution. Is it a good idea or bad idea ?)

CodePudding user response:

The lambda must be unique for specific treatment, this is why the best practice is to split your lambda to many sub components

You can use this architecture for example :

DynamoDB Stream --> Lambda --> Step Function (parralele treatment)

Or use multiple lambdas with SNS fanout like :

DynamoDB Stream --> Lambda --> SNS --> multiple sub ( lambdas)

  • Related