How to Include Metadata in DynamoDB Stream Events

0

I'm currently working on a project where I need to implement asynchronous updates in DynamoDB and send events via a Lambda function triggered by a DynamoDB Stream. The goal is to notify consumers once a batch request for updating records has been successfully executed.

In this process, users provide a unique correlationId with their request. My question is, how can the Lambda function access this metadata, such as the correlationId, the request's origin (coming from the microservice), the userID, and other custom headers? These pieces of information are metadata of the updated table data, but they don't directly relate to the table's content.

Is there a way to send metadata with each Dynamodb write requests and transactWrite requests, such that they don't get stored to the table, but still are passed to the lambda triggered through the Stream events.

I would appreciate any guidance with this.

Neisha
asked 3 months ago197 views
1 Answer
0

There is many ways to achieve this, but personally as the customer is awaiting a batch of updates to complete, I would use Transactions if you are not doing so already.

Have two tables, one for the user items that your batch updating and one for your correlationId and custom header info. Have this event trigger its own Lambda function so that it can update the user. Set a small TTL on these items, as ultimately they are not needed once they invoke the payload.

profile pictureAWS
EXPERT
answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions