This library registers and executes a function corresponding to the event of DynamoDB Stream. This can be used with AWS lambda.
cd your/lambda_function/dir
pip install dynamodb-stream-dispatcher -t ./
- create function
- append function to an instance of
DynamoStreamDispatcher
. - call
DynamoStreamDispatcher.dispatch
to execute functions by event.
DynamoStreamDispatcher passes deserialized record(DeRecord) to your functions.
DeRecord
has few variables.
variable | type | description | example |
---|---|---|---|
event_name | string | action of updates | INSERT / MODIFY / REMOVE |
region | string | AWS Region of Table | us-west-2 |
source_table | string | name of Table | ExampleTableWithStream |
old | dict | deserialized NewImage | {u'Message': u'This item has changed', u'Id': Decimal('101')} |
new | dict | deserialized OldImage | {u'Message': u'This item has changed', u'Id': Decimal('101')} |
raw | dict | raw source of record | - |
def yourfunc(rec):
## code to handle event
$ pytest -p no:warnings -v dynamodb_stream_dispatcher
- Fork it ( https://github.com/higanworks/dynamodb_stream_dispatcher/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request