Benjamin Lvovsky
Benjamin Lvovsky

Reputation: 31

How to process DynamoDB stream events with Chalice

I am writing a project where I need to process DynamoDB table inserts and updates in Chalice. I see in Chalice events processing for SNS, SQS, scheduler but not for DynamoDB table. Currently it is not in Chalice, but AWS definitely can do it. What is a recommended workaround?

I do it manually without triggering but it is not as good due to separation of concerns and modularity

I would like to have it something like:

@app.on_dynamodb_table_trigger(table='mytable', event='insert')
def myhandler(event):
    for record in event:
        domyligic()

I need my domyligic() function to be called on insert event into table 'mytable'

Upvotes: 3

Views: 918

Answers (2)

Alex R
Alex R

Reputation: 11881

This feature was added to Chalice on October 2nd, 2020:

https://aws.amazon.com/blogs/developer/aws-chalice-now-supports-amazon-kinesis-and-amazon-dynamodb-streams/

requirements.txt

chalice>=1.21

app.py

@app.on_dynamodb_record(stream_arn=os.environ['TABLE_STREAM_ARN'])
def on_table_update(event):
    for record in event:
        process_record(record)

Upvotes: 1

dmulter
dmulter

Reputation: 2748

You have a couple of options:

Upvotes: 0

Related Questions