How to Create an AWS Lambda Function to Write to a DynamoDB Table

Derek Hutson
5 min readFeb 9, 2023

Step by step demo with pictures

Lambda and DynamoDB are both very popular AWS services, and for good reason.

Lambda is a serverless compute function that lets you run code manually or automatically based on events called triggers. DynamoDB is a NoSQL database from AWS that is designed to be very fast and very scalable.

There are times where it may be helpful to create a Lambda function that can automatically write data to a DynamoDB table you have configured. It is relatively simple, all you need to do is create a table, create your function, and create an IAM role your function will use that will allow Lambda to write to your DynamoDB table.

Let’s look below at what you need to do to make this happen (we will use the AWS console), and if it is helpful you can expand on it to better fit the use case you would need this for.

  1. Create a DynamoDB table by opening the service, and clicking create table. We will call our table testTable, and since it is required to create a Partition key for every table you create we will just make one called Id. For this demo, we will leave all other table settings at their default and will not use any tags.

--

--

Derek Hutson

Practicing Kaizen in all things. Being a dad is pretty neat too.