I am using Amazonica, the Clojure library for writing to DynamoDB.
The following inserts the element into DynamoDB and updates its contents if it is called a second time, which is expected.
(ddb/put-item cred :table-name table-name :item payload)
Now the following only inserts the element for the first time. Calling him a second time does nothing that I need.
(ddb/put-item cred :table-name table-name :condition-expression "attribute_not_exists(clientId)" :item payload)
However, with the latter, I get an error message:
The conditional request failed (Service: AmazonDynamoDBv2; Status code: 400; Error code: ConditionalCheckFailedException;
... which really does not make the code accessible. My CloudFormation template is very simple:
"Resources": { "ClientTable": { "Type": "AWS::DynamoDB::Table", "Properties": { "AttributeDefinitions": [ { "AttributeName": "clientId", "AttributeType": "S" } ], "KeySchema": [ { "AttributeName": "clientId", "KeyType": "HASH" } ], "ProvisionedThroughput": { "ReadCapacityUnits": { "Ref": "ReadCapacityUnits" }, "WriteCapacityUnits": { "Ref": "WriteCapacityUnits" } }, "TableName": "ClientTable" } } }
Did I miss something?
source share