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
已提問 4 個月前檢視次數 210 次
1 個回答
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
專家
已回答 3 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南