How do I set up Time to Live (TTL) in DynamoDB?

Last updated: 2021-06-21

I want to set up Time to Live (TTL) on my Amazon DynamoDB table.

Resolution

Amazon DynamoDB TTL allows you to define a per-item timestamp to determine when an item is no longer needed. After the expiration of the TTL timestamp, DynamoDB deletes the item from your table within 48 hours without consuming any write throughput. The time taken to delete the items might vary depending on the size and activity level of your table.

To set up TTL, see Enabling Time to Live. When you create a TTL attribute in a table, keep the following in mind:

  • TTL attributes must use the Number data type. Other data types, such as String, aren't supported.
  • TTL attributes must use the epoch time format. For example, the epoch timestamp for October 28, 2019 13:12:03 UTC is 1572268323. You can use a free online converter, such as EpochConverter, to get the correct value.
    Note: Be sure that the timestamp is in seconds, not milliseconds (for example, use 1572268323 instead of 1572268323000).

Did this article help?


Do you need billing or technical support?