Skip to content

Instantly share code, notes, and snippets.

@justrandomdev
Created November 19, 2019 11:11
Show Gist options
  • Save justrandomdev/dfd71969bac7c5f75ddf4447d1e18c5e to your computer and use it in GitHub Desktop.
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.
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