Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

DynamoDB TTL does not delete an item at its expiration timestamp. It makes the item eligible for asynchronous deletion, which AWS says typically happens within a few days—not at a guaranteed deadline. Until then, the item may still appear in reads and continue to count toward storage and read costs. If an application must stop treating data as valid at a precise time, enforce that rule in application logic; use TTL as eventual cleanup.

What DynamoDB TTL does

Time to Live (TTL) is a table setting that tells DynamoDB which item attribute contains an expiration time. For each item, that attribute must be a Number holding a Unix epoch timestamp in seconds. DynamoDB ignores TTL values stored as another data type. An item without a valid timestamp is not given a usable expiration by TTL.

When the timestamp is in the past, DynamoDB marks the item as eligible for deletion. A background process removes eligible items asynchronously. AWS describes removal as typically occurring within a few days, but it may happen at any time; the timing is not a deletion deadline or guarantee. Table size and activity can affect how long cleanup takes. AWS: Using time to live (TTL) in DynamoDB and AWS: Troubleshooting time to live (TTL).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why an expired item may still be there

Expiration and physical deletion are separate events. Between them, an expired item can still be returned by reads, queries, or scans, and it can still be written to. It also continues to count toward storage and read costs until DynamoDB deletes it. AWS: Working with expired items and time to live (TTL).

#1 Best Overall

That pending period is why TTL should not be used as the only control for access, eligibility, or retention deadlines. Make the application decide whether a record is still valid, using the expiration value as part of its read or write logic.

How to keep expired items out of results

Filter Query and Scan results by the TTL timestamp when expired records must not be returned. The filter is an application-facing validity check; it does not make the item disappear from the table or replace DynamoDB’s asynchronous cleanup.

For updates during the pending period, use a condition expression that checks the item’s expiration or other relevant state. This helps make the operation safe if TTL deletion happens concurrently. Design the condition around the operation’s actual rule—for example, whether an item must still be unexpired—not around an assumption that the item will remain present until the request finishes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What TTL means for Streams and Global Tables

DynamoDB Streams can expose records for TTL deletions. In the Region where the deletion occurs, the stream identifies it as a service deletion by DynamoDB. With Global Tables, a replicated deletion in another Region does not carry the same TTL-deletion identification in that replica Region’s stream. A downstream consumer that relies on recognizing TTL events should account for this regional difference. AWS: Working with expired items and time to live (TTL).

TTL deletions replicate to replica tables in current-version Global Tables. The initial TTL deletion does not consume write capacity in the Region where expiration occurs, but replicated deletes can consume replicated write capacity in replica Regions, and applicable charges may apply. Include that distinction when estimating multi-Region cleanup costs. AWS: Using time to live (TTL) in DynamoDB.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

TTL is cleanup, not recovery

TTL is for eventual removal of expired items; it is not a way to restore deleted data. For recovery, DynamoDB point-in-time recovery (PITR) provides continuous backups with a configurable recovery window from one to 35 days. Restoring creates a new table. On-demand backups are a separate option for full-table backups and longer-term retention. Choose a backup approach based on the recovery period and retention your workload needs, rather than expecting TTL to preserve a copy. AWS: DynamoDB point-in-time recovery and AWS: DynamoDB on-demand backup and restore.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.