Skip to content

Instantly share code, notes, and snippets.

@hokkai7go
Created January 25, 2017 11:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hokkai7go/03346e0a442aa7bf5dc38fa3ad1d909c to your computer and use it in GitHub Desktop.
Save hokkai7go/03346e0a442aa7bf5dc38fa3ad1d909c to your computer and use it in GitHub Desktop.
DynamoDBのストレージ容量(バイト単位)と項目数を出したときのスクリプト
#!/bin/bash
table_list=`AWS_PROFILE=hoge aws dynamodb list-tables | jq -r '.TableNames[]'`
for table in $table_list
do
table_size=`AWS_PROFILE=hoge aws dynamodb describe-table --table-name $table| jq -r '.[].TableSizeBytes'`
if expr $table_size \< 1024 > /dev/null
then
table_size="${table_size} Bytes"
elif expr $table_size \< 10238976 > /dev/null
then
table_size=`expr $table_size / 1024`
table_size="${table_size} KB"
elif expr $table_size \< 10484711424 > /dev/null
then
table_size=`expr $table_size / 1048576`
table_size="${table_size} MB"
elif expr $table_size \< 10736344498176 > /dev/null
then
table_size=`expr $table_size / 1073741824`
table_size="${table_size} GB"
fi
table_item_count=`AWS_PROFILE=hoge aws dynamodb describe-table --table-name $table| jq -r '.[].ItemCount'`
echo "$table,$table_size,$table_item_count"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment