Created
November 19, 2019 11:11
-
-
Save justrandomdev/dfd71969bac7c5f75ddf4447d1e18c5e to your computer and use it in GitHub Desktop.
bash 1 liner to clear dynamodb item by item. This can be used when you have limited rights to a dynamodb table and cannot just delete it.
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
| IFS=$'\n'; for itm in $(aws dynamodb scan --table-name ops-cp-ue1-vault-data | jq -r '.Items[] | [.Key.S,.Path.S] | join (" ") ' | awk '{ printf "{\"Key\":{\"S\":\"%s\"},\"Path\":{\"S\":\"%1s\"}}\n",$1,$2 }'); do eval aws dynamodb delete-item --table-name ops-cp-ue1-vault-data --key '$itm'; done; unset IFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment