eoinmullan
eoinmullan

Reputation: 1199

Clear all data from a DynamoDB table without deleting it

How can I clear all items from a DynamoDb table without deleting and recreating the table? The table is created/defined using CloudFormation so I don't want to duplicate that concern in business code.

I'm using TypeScript/NodeJs.

This question says to scan every item, chunk into blocks of 25, then delete each item using BatchWrite, however:

Is there a better way? Am I missing something?

Upvotes: 1

Views: 3670

Answers (1)

Charles
Charles

Reputation: 23823

Nope, those are your only two options:

  1. delete and recreate the table
  2. (Batch) Delete each item in the table

Why is this needed?

If this really is a "common need" for your application.. Have you considered more ephemeral storage, such as Elasticache?

What about DDB's ability to automatically expire and removed items via TTL functionality?

Upvotes: 2

Related Questions