5
votes

Actually I want to implement validations on AWS DynamoDB table items, which should prevent records to insert/update if rules break for an item fields.

Is it possible?

Or Can we create a trigger lambda for dynamoDB table, that trigger before insert/update. So that we can check for validation rule and handle this.

1

1 Answers

7
votes

DynamoDB does not support database-side items validation. It only validates that when you add an item it should have attributes for your keys (partition key, sort key, etc.) and they have correct type. Apart from that DynamoDB does not validate anything.

Also since DynamoDB is schema-less and does not impose restrictions on your attributes it does not check what attributes your items have (keys is the only exception).

The only option is to validate your items on the server side before you save them into DynamoDB.

UPDATE

Can we create a trigger lambda for dynamoDB table

DynamoDB does not support Lambda triggers that are executed before an item is added to a database. The only trigger that is supported at the moment is for DynamoDB streams, but it is called after an item is stored in a table and it is called asynchronously, meaning that there is a small delay between an item is added and a trigger is executed.