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
gefragt vor 4 Monaten210 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor 3 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen