Last active
July 12, 2022 18:56
-
-
Save k3karthic/4bc929885eef40dbe010 to your computer and use it in GitHub Desktop.
Truncate all keys in a dynamodb table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
See
--select SPECIFIC_ATTRIBUTES
inaws dynamodb scan help
to tune the key.