Reputation: 243469
I need to find all DynamoDB existing table names that start with a given string.
What is the best/recommended way to do this?
I need to do this, for example to find all tables, whose name starts with "__Test__"
and then delete all these tables.
Upvotes: 2
Views: 2352
Reputation: 47249
To do it programmatically, you would have to do it in these steps.
ListTables
APIDeleteTable
on any table that has a name matching the "__Test__"
patternThere is also some requirements for calling DeleteTable
regarding the table state. From the documentation:
The DeleteTable operation deletes a table and all of its items. After a DeleteTable request, the specified table is in the
DELETING
state until DynamoDB completes the deletion. If the table is in theACTIVE
state, you can delete it. If a table is in CREATING orUPDATING
states, then DynamoDB returns a ResourceInUseException. If the specified table does not exist, DynamoDB returns a ResourceNotFoundException. If table is already in theDELETING
state, no error is returned.
If you only need to do this to a few tables and not recurring, you can go to the AWS DynamoDB console and (after selecting the right region) delete the table directly in the UI.
Upvotes: 3