How to convert from DynamoDB wire protocol to native Python object manually with boto3?
I have a similar situation and I used the following an approach like this:
from boto3.dynamodb.types import TypeDeserializer
deser = TypeDeserializer()
...
<in handler>
for record in event['Records']:
old = record['dynamodb'].get('OldImage')
new = record['dynamodb'].get('NewImage')
if old:
d = {}
for key in old:
d[key] = deser.deserialize(old[key])
This approach works for me. The resulting dictionary d
contains the converted object rather than the wire-format version passed to the handler.