Last active
June 5, 2020 16:59
-
-
Save IslamWahid/f51de13f27e3602a0ad1ebb9e7b3bd2a to your computer and use it in GitHub Desktop.
clear all items in a dynamo db table
This file contains 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
#!/usr/bin/env zsh | |
local PARTITION_KEY='hashKey' | |
local SORT_KEY='sortKey' | |
local TABLE_NAME='table' | |
aws dynamodb scan \ | |
--attributes-to-get $PARTITION_KEY $SORT_KEY \ | |
--table-name $TABLE_NAME --query "Items[*]" | | |
jq --compact-output '.[]' | | |
tr '\n' '\0' | | |
xargs -0 -t -I keyItem aws dynamodb delete-item --table-name $TABLE_NAME --key=keyItem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment