Skip to content

Instantly share code, notes, and snippets.

@IslamWahid
Last active June 5, 2020 16:59
Show Gist options
  • Save IslamWahid/f51de13f27e3602a0ad1ebb9e7b3bd2a to your computer and use it in GitHub Desktop.
Save IslamWahid/f51de13f27e3602a0ad1ebb9e7b3bd2a to your computer and use it in GitHub Desktop.
clear all items in a dynamo db table
#!/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