question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing DdbJson from DynamoDB Streams events

See original GitHub issue

When you use DynamoDB Streams and handle item changes with Lambda, the incoming events look like this:

{
    "Records": [
        {
            "eventID": "7de3041dd709b024af6f29e4fa13d34c",
            "eventName": "INSERT",
            "eventVersion": "1.1",
            "eventSource": "aws:dynamodb",
            "awsRegion": "region",
            "dynamodb": {
                "ApproximateCreationDateTime": 1479499740,
                "Keys": {
                    "Timestamp": {
                        "S": "2016-11-18:12:09:36"
                    },
                    "Username": {
                        "S": "John Doe"
                    }
                },
                "NewImage": {
                    "Timestamp": {
                        "S": "2016-11-18:12:09:36"
                    },
                    "Message": {
                        "S": "This is a bark from the Woofer social network"
                    },
                    "Username": {
                        "S": "John Doe"
                    }
                },
                "SequenceNumber": "13021600000000001596893679",
                "SizeBytes": 112,
                "StreamViewType": "NEW_IMAGE"
            },
            "eventSourceARN": "arn:aws:dynamodb:region:123456789012:table/BarkTable/stream/2016-11-16T20:42:48.104"
        }
    ]
}

Is there any way to parse the NewImage into the dotnet model?

DdbJsonReader is marked as internal and DynamoDbLowLevelContext does not expose such functionality.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lezzicommented, Jul 24, 2023

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 LambdaSerializer class from that branch, we should be able to polish it and add it to the library 🤔 .

0reactions
wjaxcommented, Jul 25, 2023

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 LambdaSerializer class from that branch, we should be able to polish it and add it to the library 🤔 .

Many many thanks! I will come back after having tested it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using AWS Lambda with Amazon DynamoDB streams
Tutorial: Using AWS Lambda with Amazon DynamoDB streams. In this tutorial, you create a Lambda function to consume events from an Amazon DynamoDB...
Read more >
How to get the pure Json string from DynamoDB stream ...
My Question is how can i get the pure json string of the DynamoDB item that's been sent over the stream? I'm using...
Read more >
Parse DynamoDB Stream events? · Issue #1212
I receive a JSON from a DynamoDB stream in a process, and I would like to parse the NewImage into a "normal" hash,...
Read more >
DynamoDB Streams - The Ultimate Guide (w/ Examples)
Learn all about Amazon DynamoDB Streams, how to use them with AWS Lambda, their uses cases, best practices, examples and more.
Read more >
Using DynamoDB Streams Lambda Made Easy - Learn
The combination of DynamoDB Streams and AWS Lambda unlocks many powerful design patterns. This exercise will show you how to use a Lambda ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found