I am trying to use DynamoDB operation BatchWriteItem
, wherein I want to insert multiple records into one table.
This table has one partition key and one sort key.
I am using AWS lambda and Go language.
I get the elements to be inserted into a slice.
I am following this procedure.
Create PutRequest
structure and add AttributeValues for the first record from the list.
I am creating WriteRequest
from this PutRequest
I am adding this WriteRequest
to an array of WriteRequests
I am creating BatchWriteItemInput
which consists of RequestItems
, which is basically a map of Tablename and the array of WriteRequests
.
After that I am calling BatchWriteItem
, which results into an error:
Provided list of item keys contains duplicates.
Any pointers, why this could be happening?
You've provided two or more items with identical primary keys (which in your case means identical partition and sort keys).
Per the BatchWriteItem docs, you cannot perform multiple operations on the same item in the same BatchWriteItem request.