Reputation: 165
Is there a way to remove a record/row from DynamoDB without using the hash key and range key?
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
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