Is there anyway to prevent a DynamoDB stream from triggering a lambda upon every DynamoDB change?
A DynamoDB stream is setup to trigger a lambda function. The lambda is at the end of a step function, and the DynamoDB table is updated in a few places throughout the step function. But those aren't the updates the lambda needs from the stream. So it's prematurely triggering the lambda before the lambda needs to invoke, and causing the lambda to trigger several times throughout the duration of the step function. This causes all sorts of problems.
One very specific change to the DynamoDB table is what's needed to trigger the lambda. That change doesn't come from the step function, but from a UI via GraphQL. The lambda needs to be able to run at both the end of the step function and whenever that change happens on the UI.
Basically, there are two scenarios when the lambda is supposed to run: 1) at the end of the step function, and 2) when the DynamoDB table is updated in the UI, bypassing the step function.
I'm writing code that stops the lambda execution if it's not the desired DynamoDB change, but that doesn't seem right...don't want it to constantly invoke if it doesn't need to. In the lifecycle of the step function, the DynamoDB table can change several times, before it ever reaches the lambda.
These numbers aren't exact, but say the step function will run 10 times in a row, then it'll update the DynamoDB 3 times. That's 30 times the lambda will be invoked, before the step function has ever triggered the lambda like it's supposed to. Is there anyway to prevent those lambda invocations?