Benjamin Collignon
Benjamin Collignon

Reputation: 130

Purge / Delete multiple items from a DynamoDB

In order to maintain the size of a Dynamodb acceptable. I need to have a triggerable and periodic way of purging the database. It seems that Amazon DynamoDB supports a BatchWriteItem action for deleting multiple items at the same time. What's the best way to do it?

Upvotes: 0

Views: 224

Answers (1)

E.J. Brennan
E.J. Brennan

Reputation: 46859

Have you considered using the built-in TTL feature:

Time to Live (TTL) for Amazon DynamoDB lets you define when items in a table expire so that they can be automatically deleted from the database. With TTL enabled on a table, you can set a timestamp for deletion on a per-item basis, allowing you to limit storage usage to only those records that are relevant.

TTL is useful if you have continuously accumulating data that loses relevance after a specific time period (for example, session data, event logs, usage patterns, and other temporary data). If you have sensitive data that must be retained only for a certain amount of time according to contractual or regulatory obligations, TTL helps you ensure that it is removed promptly and as scheduled.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html

Upvotes: 2

Related Questions