How to setup a dynamo db trigger in AWS lambda function

179 views Asked by At

I am new to AWS lambda and have a doubt in mind. I have a dynamodb table("People") and in that table I have one attribute called "SeniorCitizen". By default the attribute is set to Yes/No based on another attribute "Age".

At some point of time Age attribute gets updated on the table and based on that I want my lambda function to be triggered to update the SeniorCitizen attribute value from No to Yes if Age gets passed 60 for a particular person.

So how can I set my trigger to check the age in the table when the table gets updated and trigger my lambda function to perform the actual update of SeniorCitizen attribute?

1

There are 1 answers

2
Mark B On

Once you configure DynamoDB to trigger a Lambda function, it will trigger the function on every record update. There is no way to tell DynamoDB to only trigger the Lambda function when a specific field is updated.

You simply need to configure the Lambda function to check if Age and SeniorCitizen values do not match, and have it perform an update to the DynamoDB record if not, using the AWS SDK for the programming language your Lambda function is written in.