Rahul Sahotay
Rahul Sahotay

Reputation: 165

find a row from DynamoDB w/o hash and range key and delete it

Is there a way to remove a record/row from DynamoDB without using the hash key and range key?

Here is my table look like: enter image description here

I have a value of instance_id and based on that I would delete the row but getting errors:

here is the code I am using:

            table.delete_item(
                Key={
                    'instance_id':'i-0b2b314a'
                }
            )

Upvotes: 2

Views: 398

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269131

The delete_item() documentation says:

Deletes a single item in a table by primary key.

So, it is not possible to delete by a value that is not the primary key.

You would need to scan (expensive in terms of RCUs!) for the rows with that value, then delete the returned items.

Upvotes: 3

Related Questions