# One-time Scheduled Events

**URL:** <https://forum.serverless.com/t/one-time-scheduled-events/2905>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [October 17, 2017, 12:44am UTC](https://forum.serverless.com/t/one-time-scheduled-events/2905 "2017-10-17T00:44:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![damianesteban](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/damianesteban/32/919_2.png) [@damianesteban](https://forum.serverless.com/u/damianesteban)\
**Post date:** [October 17, 2017, 12:44am UTC](https://forum.serverless.com/t/one-time-scheduled-events/2905/1 "2017-10-17T00:44:52Z")

</div>

Hello. I know that it is possible to schedule recurring events with Cloudwatch, i.e. `rate(5 minutes)`, but I am writing a notification service and need to schedule one-time events, i.e.:

_On December 12th, 2017 at 8:37 pm send a notification._

Can anyone point me in the right direction?

Thank you.

---

<div class="post-metadata">

**Author:** ![TrentBartlem](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/trentbartlem/32/627_2.png) [@TrentBartlem](https://forum.serverless.com/u/TrentBartlem)\
**Post date:** [October 17, 2017, 3:30am UTC](https://forum.serverless.com/t/one-time-scheduled-events/2905/2 "2017-10-17T03:30:07Z")

</div>

> [@Set scheduled event dynamically](http://forum.serverless.com/t/set-scheduled-event-dynamically/2814/2):
>
> Store the trigger records in DynamoDB - multiple triggers means multiple records, each with a different execution time. Enable Time To Live in DynamoDB and configure that table such that when the execution time is reached, the record will be deleted. Create a lambda that listens to DynamoDB deletion events. When it detects that an event should be triggered, it does so, using the data sent from dynamo.

---

<div class="post-metadata">

**Author:** ![damianesteban](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/damianesteban/32/919_2.png) [@damianesteban](https://forum.serverless.com/u/damianesteban)\
**Post date:** [October 17, 2017, 2:59pm UTC](https://forum.serverless.com/t/one-time-scheduled-events/2905/4 "2017-10-17T14:59:55Z")

</div>

I was under the impression that when you add the ttl to dynamodb, the item is not _actually_ deleted up until an hour later.

---

<div class="post-metadata">

**Author:** ![damianesteban](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/damianesteban/32/919_2.png) [@damianesteban](https://forum.serverless.com/u/damianesteban)\
**Post date:** [October 17, 2017, 11:26pm UTC](https://forum.serverless.com/t/one-time-scheduled-events/2905/5 "2017-10-17T23:26:18Z")

</div>

Sorry, can you elaborate on that a bit?

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [October 18, 2017, 5:59am UTC](https://forum.serverless.com/t/one-time-scheduled-events/2905/6 "2017-10-18T05:59:58Z")

</div>

You should be able to use the CloudWatch Event API to schedule an event that triggers your Lambda at the correct time.

---

<div class="post-metadata">

**Author:** ![jthomerson](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jthomerson/32/481_2.png) [@jthomerson](https://forum.serverless.com/u/jthomerson)\
**Post date:** [October 20, 2017, 6:29pm UTC](https://forum.serverless.com/t/one-time-scheduled-events/2905/7 "2017-10-20T18:29:16Z")

</div>

As @damianesteban mentioned, timing is not guaranteed. In our use case, we’ve actually seen items not be deleted for several days past their TTL. DynamoDB expiration is **not** meant to be used for precision timing.

See: [How it works: DynamoDB Time to Live (TTL) - Amazon DynamoDB](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html) where it says:

> DynamoDB typically deletes expired items within 48 hours of expiration. The exact duration within which an item truly gets deleted after expiration is specific to the nature of the workload and the size of the table. Items that have expired and not been deleted will still show up in reads, queries, and scans.

---

<div class="post-metadata">

**Author:** ![damianesteban](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/damianesteban/32/919_2.png) [@damianesteban](https://forum.serverless.com/u/damianesteban)\
**Post date:** [October 20, 2017, 10:12pm UTC](https://forum.serverless.com/t/one-time-scheduled-events/2905/8 "2017-10-20T22:12:20Z")

</div>

The way we currently solved this is by polling a DynamoDB table every 5 minutes. If DynamoDB TTL didn’t have that delay it would be fantastic because it would take care of both scheduling and removing the item in one shot.
