3

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'

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470

2 Answers2

1

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)
Alex R
  • 11,364
  • 15
  • 100
  • 180
0

You have a couple of options:

dmulter
  • 2,608
  • 3
  • 15
  • 24