I am using Amazonica, a Clojure library to write to DynamoDB.
The following inserts an item into DynamoDB and updates its content if called a second time, which is expected.
(ddb/put-item cred
:table-name table-name
:item payload)
Now, the following inserts an item only the first time. Calling it a second time doesn't do anything, which is what I need.
(ddb/put-item cred
:table-name table-name
:condition-expression "attribute_not_exists(clientId)"
:item payload)
However with the latest I am getting an error:
The conditional request failed (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ConditionalCheckFailedException;
... which doesn't really make the code deliverable. 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"
}
}
}
Am I missing something?