I want to be able to send failed lambda events to an sqs queue for later processing, a la https://docs.aws.amazon.com/lambda/latest/dg/dlq.html . Is this possible in chalice?
Yes this is possible in chalice.
Here is an example:
{
"version": "2.0",
"app_name": "name",
"dead_letter_queue_target_arn": "arn:aws:sqs:XXX:",
"stages": {
"dev": {}
}
}
Interesting - not tied to stage? would be nice to spec different DLQs for stag vs prod
I'm also having problems finding documentation or even source code that seems relevant here - links to either appreciated
This is not currently possible in chalice but I think something worth adding. Marking as a feature request. Thanks for the feedback.
@jfhbrook
But with a generic DLQ for all stages you can trigger a Lambda Function and separate the Stages in the Function.
Suggested format for using:
@app.on_sqs_message(queue='my_queue_name', batch_size=1, dead_letter_queue='my_dlq_name')
def ingest(event):
pass
That could then generate the queue ARN and update the lambda config
"DeadLetterConfig": {
"TargetArn": "string"
}
Not sure how the permission generation works, but this could also update the policy to add permissions for writing to the DLQ.
Or is it more desirable to configure via the config.json? Then it would be possible to configure per stage.
Has anyone had any success with the solution @Meschkov posted? I tried to configure it this way, but, upon deployment, the dead letter queue wasn't actually set up and I had to manually assign the DLQ to each lambda in the console.
I also couldn't find anything in the documentation that references the dead_letter_queue_target_arn configuration option and am curious if that is still the way to go about it.
Just to clarify, this isn't possible in chalice just yet, but I'd like to add support for it. I think for now it makes sense to just add this in the config.json. We can look into adding it in app.py in the future.
Thanks for the clarification, @jamesls !
I think for now it makes sense to just add this in the config.json
Exactly how would one do this? Like I said above, I tried copying what @Meschkov posted, but it seemed to not have any effect.
Also, with a little bit of guidance on the entry point to a change like this (I've only looked at the deployer code a little), I'd be happy to work on this and submit a PR.
I also would love to see support for DLQ in Chalice. SNS implementation is not ready for production without it.
Most helpful comment
Suggested format for using:
That could then generate the queue ARN and update the lambda config
Not sure how the permission generation works, but this could also update the policy to add permissions for writing to the DLQ.
Or is it more desirable to configure via the
config.json? Then it would be possible to configure per stage.