I have about 50 tables in DynamoDB and I'm looking for a way to find size of all tables.
aws dynamodb describe-table --table-name [table name]
I know above command returns TableSizeBytes, but is this the only way to get size of table? Do I have to run this command for all tables in picture? Also, what is the cost of running this command?
Just write a script and loop over all your tables. As already stated there's no cost for running the command.
For example:
#!/usr/bin/env bash
YOUR_DYNAMODB_TABLES=( "table1" "table2" "table3" )
TOTAL_SIZE=0
for TABLE in "${YOUR_DYNAMODB_TABLES[@]}"
do
SIZE=$(aws dynamodb describe-table --table-name "$TABLE" | jq '.Table.TableSizeBytes')
TOTAL_SIZE=$((TOTAL_SIZE + SIZE))
done
echo $TOTAL_SIZE