Skip to content
Related Articles

Related Articles

AWS DynamoDB – Insert Data Using AWS Lambda

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 18 Apr, 2022

In this article, we will look into the process of inserting data into a DynamoDB table using AWS Lambda. Amazon DynamoDB is a completely owned NoSQL proprietary provider that helps key-price and textual statistics systems and is supplied via way of means of as a part of Amazon Web Services. AWS Lambda is an event-driven, serverless computing platform supplied via way means of Amazon as part of Amazon Web Services. It is a computing service that runs code without us worrying about servers.


Follow the below steps to insert data into the DynamoDB table using AWS lambda:

Step 1: Login into AWS console.

Step 2: Search for dynamodb.


Step 3: Select Dynamodb and press on create table


Step 4: Now give the table name and keys accordingly to your requirement 


Now table will be created.

Step 5: Now we need to create Identity and Access Management(IAM) role for that go and search for IAM role.

Step 6: Click on role in access management and click on create role.



Step 7: Here we need to select AWS service and lambda.


Step 8: Here we need to add permission, as we are using dynamo db we need to add AmazonDynamoDBFullAccess Permissions policies


Step 9: Now give the role name and select create role


Step 10: Press on create function.


Step 11: Give name and Runtime.


Step 12: Change the Execution role to Use an existing role and select your role.


Step 13: Now go to the code section and add the below code.


#importing packages
import json
import boto3
#function definition
def lambda_handler(event,context):
    dynamodb = boto3.resource('dynamodb')
    #table name
    table = dynamodb.Table('sample')
    #inserting values into table
    response = table.put_item(
            'sample': 'bhagi',
    return response



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!