-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing DdbJson from DynamoDB Streams events #178
Comments
Hey @thebogusman, I think you are right and at the moment the required classes are internal. We had plans to inject EfficientDynamoDb into the lambda pipeline, but it is still in the planning phase. What type does your lambda accept as an input right now? If you are able to receive a It may look like this: public void MyHandler(Stream stream)
{
var records = LambdaSerializer.Deserialize(stream);
} |
Hi @lezzi, thanks for responding! Actually, there's no lambda yet. We're still in the discovery pahse, so I'm quite flexible when it comes to the request type. Both Your example looks really nice. Do I get it right, that in the basic version |
Hi @lezzi I am in this same situation. Is there anything that I can do? Many thanks |
I have already exposed public async Task<Document?> GetDocumentFromStreamAsync(Stream stream, CancellationToken cancellationToken = default)
{
var result = await DdbJsonReader.ReadAsync(stream, GetItemParsingOptions.Instance, false, cancellationToken).ConfigureAwait(false);
return result.Value;
} However all atributes are marked as "Map" because they are objects inside the json. |
When I compile an event where the NewImage is the json in NON-DDB format, it works. Standard. Works {
"NewImage": {
"ActionObject": "e2dc1a2a-08d9-43c9-b677-d5bf17cad9db",
"ResourceType": "access-point"
}
} DDB JSON (format in the events). Does not work {
"NewImage": {
"ActionObject": {
"S": "e2dc1a2a-08d9-43c9-b677-d5bf17cad9db"
},
"ResourceType": {
"S": "access-point"
}
}
} |
Hey @wjax, sorry for the late reply. A long time ago I was experimenting with lambda and here is the example that parses a lambda stream into the request object. It is also a good example of how to deserialize and map a DynamoDb JSON into a class. It is possible but requires applying attributes in certain cases (one of the reasons it is internal). If you are up for testing the |
I wish I knew about this haha! I had the same problem and had to use the AWS DynamoDB SDK to do this for lambdas that stream from DynamoDB. But there's an issue with the EfficientDynamoDb doesn't have this problem because it exposes the type here |
Many many thanks! |
When you use DynamoDB Streams and handle item changes with Lambda, the incoming events look like this:
Is there any way to parse the
NewImage
into the dotnet model?DdbJsonReader
is marked as internal andDynamoDbLowLevelContext
does not expose such functionality.The text was updated successfully, but these errors were encountered: