Skip to content

Instantly share code, notes, and snippets.

@gautierdag
Created June 11, 2021 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gautierdag/653cbf0895392b45aac1d5f24fab470a to your computer and use it in GitHub Desktop.
Save gautierdag/653cbf0895392b45aac1d5f24fab470a to your computer and use it in GitHub Desktop.
Make all DynamoDB Tables On-Demand - Use with caution ⚠️
for name in $(aws dynamodb list-tables | jq .TableNames)
do
l=${#name}
if [ ${#name} -le 3 ]; then echo "Skipping name!"
else
short=${name:1:l-2} # clean json string representation of dataset
if [ "${short: -1}" == '"' ]
then short=${name:1:l-3}
fi
echo "Updating Table: ${short}"
aws dynamodb update-table --table-name ${short} --billing-mode PAY_PER_REQUEST > "${short}_response.json"
sleep 30 # long sleep so that tables have time to be updated (AWS has max limit of 50 tables updating at once)
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment