Reputation: 31
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
Reputation: 11881
This feature was added to Chalice on October 2nd, 2020:
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
Reputation: 2748
You have a couple of options:
Contribute to the Chalice project in GitHub to build out the existing proposal to Add support for Kinesis and DynamoDB stream events.
Use the Chalice pure Lambda function decorator to create your handler. Separately code the logic to configure this Lambda function on a DynamoDB stream using boto3. You can find details in Using AWS Lambda with Amazon DynamoDB.
Upvotes: 0