I have stepfunction for calculating operation cost of Departments. Each department consists of Employees. Employee is individual records in dynamo with fields (EmpId, Salary, Salary_Status(Processed, Pending, Not_Eligible))
Department operation cost Stepfunction example: Runs for individual departments
Start -> Step1: updateEmployeeSalaryLambda -> step2: wait for employee salary to be updated(Dynamo) -> doFoo() -> End
Is there a way to do the dynamo check from stepfunction directly .i.e check if all employees in a particular department have Salary_Status == Paid?
Thanks for all the help
There are two ways of doing it.
Introduce a sort key. Possible sort key design for your application may be:
[Department]#[Salary_Status]. You can query it from anotherLambdawithin yourStep Function. If you know how many employees are in the department, you can count if the number matches the count of found paid employees. Another option is to check how many employees don't have Paid status (refer to this).If you need more complex query you can also leverage secondary index.