Skip to content

Instantly share code, notes, and snippets.

@timchan-lumoslabs
Forked from k3karthic/truncate_dynamodb.sh
Last active June 23, 2016 00:55
Show Gist options
  • Save timchan-lumoslabs/0193ad1fb93eb33591cf1d0561c876aa to your computer and use it in GitHub Desktop.
Save timchan-lumoslabs/0193ad1fb93eb33591cf1d0561c876aa to your computer and use it in GitHub Desktop.
Truncate all keys in a dynamodb table
#!/bin/bash
TABLE_NAME=$1
# Get id list
aws dynamodb scan --table-name $TABLE_NAME --profile default | grep ID | awk '{ print $2 }' > ~/bin/truncate.list
# Delete from id list
cat ~/bin/truncate.list | xargs -IID aws dynamodb delete-item --table-name $TABLE_NAME --key '{ "id": { "S": "ID" }}'
# Remove id list
rm ~/bin/truncate.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment