Reputation: 635
We make heavy use of DynamoDB tables (over 1000). But I suspect some tables are not being used, and are empty. I would like to get a list of those tables, so that I can delete them, and save money.
Upvotes: 3
Views: 361
Reputation: 635
The following (relatively disgusting) shell command will return a list of empty DynamoDB tables.
aws dynamodb list-tables --output table --query 'TableNames' | tail -n +4 | tail -r | tail -n +2 | tail -r | cut -d " " -f 3 | xargs -I{} -L 1 bash -c "aws dynamodb describe-table --query 'Table.ItemCount' --table-name {} && echo {}" | awk '/0/{getline; print}'
The repeated tail
commands are a workaround for OS X's head
command not supporting head -n +2
.
Upvotes: 3