I have Lambda Function which attached to DynamoDB change event. The Lambda is triggering twice when I change/modify an item in the Test-machines table in the DynamoDB.
I am modifying IsMachineOn
value from True
to False
, It is trigger Test-Machine-On-alert-status
Lambda function twice.
I am not understanding why two-time lambda is a trigger.
I observed a small change in the records
in the event
parameter of Lambda.
For first trigger,
Value of NewImage["IsMachineOn"]["BOOL"]
is False
Value of OldImage["IsMachineOn"]["BOOL"]
is True
For Second trigger,
Value of NewImage["IsMachineOn"]["BOOL"]
is False
Value of OldImage["IsMachineOn"]["BOOL"]
is False
I have business logic on NewImage["IsMachineOn"]["BOOL"]==False
so that my business logic is running twice.
There are two things:
- Why Lambda is running twice?
- What will be a workaround to fix this issue?