Skip to content

Instantly share code, notes, and snippets.

@toshke
Forked from k3karthic/truncate_dynamodb.sh
Created September 28, 2017 00:15
Show Gist options
  • Save toshke/6038773fbc76c768c83d2fc9475656ac to your computer and use it in GitHub Desktop.
Save toshke/6038773fbc76c768c83d2fc9475656ac 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 | grep ID | awk '{ print $2 }' > /tmp/truncate.list
# Delete from id list
cat /tmp/truncate.list | xargs -IID aws dynamodb delete-item --table-name $TABLE_NAME --key '{ "id": { "S": "ID" }}'
# Remove id list
rm /tmp/truncate.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment