You can can use:
aws dynamodb batch-write-item --request-items file:///tmp/deletes.json
where the file /tmp/deletes.json
must have this structure like this:
{
"MY_TABLE": [
{
"DeleteRequest": {
"Key": {
"partition-key-name": {
"S": "value to delete"
},
"sort-key-name": {
"S": "value to delete"
}
}
}
},
{
"DeleteRequest": {
"Key": {
"partition-key-name": {
"S": "another value to delete"
},
"sort-key-name": {
"S": "another value to delete"
}
}
}
},
...
]
}
You can remove several items with a single batch.
For my specific scenario, I ahve a table with PK and SK as accountId and profileId. there are multiple accountIds and multiple profileIds under each accountID. I want to delete all items with a specific PK e.g. PK = "1234".