Performing CRUD Operations on DynamoDB using Lambda

Performing CRUD Operations on DynamoDB using Lambda

Hello connections!! I am happy to share this one of the interesting task that we can do with AWS cloud. I will briefly give you a idea on this task . In this article , I want to make others understand that how data will be stored in backend(DynamoDB) using lambda

Let's create a DynamoDB Table , which is a NOSQL database.

No alt text provided for this image

click on create table .

No alt text provided for this image

Create a table with name "employee" along with partition key as "eid" and sort key as "ename".

No alt text provided for this image

leave remaining settings as default and create table.

No alt text provided for this image

wait till the status of table becomes active . Now Let's create a lambda function .Create a lambda function with a pre defined template Hello-world-function with python 3.7.

No alt text provided for this image

Lets create a IAM role with Lambda as use case with DynamoDBFullAccess as permission policy. Lets create a role now.

No alt text provided for this image

create role

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Give a role name for that role , keep remaining details as default and click on create role.

No alt text provided for this image

wait until the role is created !!

Lets go back to lambda function.

No alt text provided for this image

choose the role we created, leave remaining settings as default and click on create function.

No alt text provided for this image

this the function for inserting record.

No alt text provided for this image

give the details which u want to insert in demoevent

No alt text provided for this image

run the function to see the code compilation.

No alt text provided for this image

our record is inserted in the DynamoDB Table.

No alt text provided for this image

similarly , we insert 2nd record in DynamoDB using lambda function. we will just change the values in the demoevent and will test the code.

No alt text provided for this image

Code for Deleting the record in the table.

No alt text provided for this image

provide the partition key and sort key of the record which we want to delete.

No alt text provided for this image

run the code . It is successfully executed.

No alt text provided for this image

the record is deleted.

No alt text provided for this image

displaying the items in the table

No alt text provided for this image

Lets insert a item manually in the table , to demonstrate updation.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

provide the partition key and sort key in the demoevent of the record , in which you want to perform the updation operation.

No alt text provided for this image
No alt text provided for this image

item Updated Successfully in the Table !!!.

To view or add a comment, sign in

More articles by Padma Sai

Others also viewed

Explore content categories