learn icon indicating copy to clipboard operation
learn copied to clipboard

Lambda Triggers on New Items

Open bryannevega opened this issue 5 years ago • 1 comments

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?

bryannevega avatar Jul 05 '20 22:07 bryannevega

I think there are 2 parts to your question -

  1. Lambda triggers for new items created in DynamoDB
  2. 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.

zachjonesnoel avatar Aug 17 '21 16:08 zachjonesnoel