Lambda Triggers on New Items
Hello,
In order to perform some actions when a new object is created, can I just hook the DynamoDB table created by Amplify and trigger SNS/Lambda?
Would Amplify run onto issues if I update the objects from Lambda? (Example, I saved the item id=123 value="data" -> value="newData" and it would sync back to the devices?
I think there are 2 parts to your question -
- Lambda triggers for new items created in DynamoDB
- Syncing your device with the latest added item/changed item.
Well, both of it is possible but as separate solutions -
Sol. for (1) you can enable DynamoDB streams and have a Lambda function as a trigger which will get invoked every time there is a change in data (newly created items, modified items, deleted items).
Sol. for (2) you can leverage DataStores from Amplify to make sure the sync happens smoothly. ( Or ) From the Lambda fn which gets invoked (Sol 1), you can call a AppSync mutation which would send the data to the connected client. (Note. Your Lambda fn would require permissions to invoke AppSync and also your mutation should allow with iam_role access rights.