Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Validation rules for AWS DynamoDB table

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.

like image 420
Sudhanshu Avatar asked Jul 27 '17 10:07

Sudhanshu


People also ask

Does Amazon DynamoDB support conditional operations?

Yes, like all the other database management systems, DynamoDB also supports all the conditional operators, User can specify a condition that is satisfied for a put, update, or delete operation to work on an item.

How do I restrict access to DynamoDB table?

Go to the IAM console to attach this policy. In the IAM console, click Roles, and then click Create New Role. Enter a name for the role and click Continue. In the Select Role Type pane, choose Role for Web Identity Provider Access and click Select.

Which DynamoDB feature allows you to set an expiry on table?

Time to Live example The ExpirationTime attribute is set as the TTL attribute on the table (not all of the attributes on each item are shown). In this example, each item has an ExpirationTime attribute value set when it is created.

How do I enable auto scaling in DynamoDB?

Choose the table that you want to work with and select the Additional settings tab. In the Read/write capacity section, select Edit. In the Capacity mode section, select Provisioned. In the Table capacity section, set Auto scaling to On for Read capacity, Write capacity, or both.


1 Answers

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.

like image 166
Ivan Mushketyk Avatar answered Sep 21 '22 13:09

Ivan Mushketyk