DynamoDB Stream
Handler
Processes DynamoDB Stream records and writes results to a destination table.
Source code in templates/stream/handler.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
__init__(repository)
Initialize the handler with a destination repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repository
|
Repository
|
The repository used to write processed items. |
required |
Source code in templates/stream/handler.py
25 26 27 28 29 30 31 | |
handle_record(record)
Handle a single DynamoDB Stream record.
Processes INSERT and MODIFY events by transforming and writing the new image to the destination table. Handles REMOVE events by deleting the corresponding item from the destination table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
DynamoDBRecord
|
The DynamoDB Stream record to process. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the record cannot be transformed into a |
Source code in templates/stream/handler.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
main(event, context)
Lambda entry point for the DynamoDB Streams handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
dict
|
The DynamoDB Streams event containing a batch of records. |
required |
context
|
LambdaContext
|
The Lambda execution context. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A partial batch response indicating which records failed processing. |
Source code in templates/stream/handler.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |