sdds
sdds

Reputation: 31

Polling dynamodb for value change

Currently learning AWS workflow with lambda. I'm trying to trigger a 302 redirect when a boolean becomes true held in DynamoDB. I have no idea how to poll DynamoDB with lambda and then send the redirect back to the client through API gateway. Do I need to be using a websoket?

Upvotes: 1

Views: 2536

Answers (3)

Chris Pollard
Chris Pollard

Reputation: 1780

You should look into AWS AppSync. It has this type of functionality built in using better methods than polling but without the same effort of implementing web sockets in API Gateway.

Here is the page on subscriptions in AppSync: https://docs.aws.amazon.com/appsync/latest/devguide/real-time-data.html

Upvotes: 0

Rajesh Kumar
Rajesh Kumar

Reputation: 54

Using websocket will be a good option to notify client from Lambda. Same situation i had recently where i have show notifications on certain client machines. API Gateway cannot be used as API gateway is binded with request. But here in your case you would not be creating any request to Lambda. You have to read dynamoDB event and notify client using websocket.

  1. You may create websocket connection and save it maybe in dynamoDB.
  2. You have to consume the dyanmoDB event in a Lambda. Check the flag. Get all the saved websockets in dynamoDB and send notification to each of them.
  3. please remember to update dyanmoDB table in case any of websocket connection is getting closed.

In order to poll the dyanmoDB event. You may consume the dynamoDB event in your lambda function and based on the payload available in your polled request. You may send notifications.

Upvotes: 2

Rishikesh Darandale
Rishikesh Darandale

Reputation: 3310

I am not still clear about your requirement.

Using dynamodb streams to trigger the lambda is possible. Dynamodb stream let you know all the events on the documents e.g. new document inserted, document updated with details of the field that got updated.

Upvotes: 0

Related Questions