3
votes

I am coming from relational database background, and I am trying to experiment with AWS services. I have a dynamoDb table with following record:

 ------------------------------------------------
 | Id | Start Timestamp | End Timestamp | Data  |
 ------------------------------------------------

Both start and end timestamps are future timestamps and I want to trigger a AWS Lambda function when start timestamp or end timestamp arrives.

To clarify by 'arrives' I mean when start/end timestamp is equal to current timestamp, is it possible to trigger a Lambda function when this happens.

Is it possible by DynamoDb streams? I wanted a reactive way to solve this problem not the usual way to poll the Db and trigger Lambda function when actual timestamp arrives.

Thanks in advance

1

1 Answers

4
votes

There's no way to do this without constantly polling DynamoDB to see if you have arrived at a certain time, and then triggering the Lambda function if you have. In other words there is no mechanism that is going to automatically initiate anything based on a timestamp you have stored in DynamoDB. You would have to implement that mechanism yourself by polling DynamoDB regularly and comparing the timestamps to the current time.

There is a mechanism to trigger Lambda functions at a given date/time, but it isn't driven by DynamoDB. It is AWS Lambda Scheduled Events. You could programmatically create those schedules. If you want that to be driven by DynamoDB then you could setup a separate Lambda function that is triggered by new DynamoDB records, which would take the timestamp in the new record and create a Lambda Scheduled Event from that.