I use an AWS Lambda function which is invoked by an S3 event and when run successfully it adds a Success entry in a database. In case of failure I would like to add Error to the database. A simple way to handle this is the destination feature.
The easiest way to handle errors would, I guess, be to use destinations to invoke another Lambda function in case of failure which then adds the Error entry to the database. However, in most tutorials and documentations I read that SQS queues are used for failures.
This would be another possibility where the destination directs to an SQS queue and the second Lambda is invoked by the SQS event. This looks more complicated to me but maybe I am missing some advantages.
What are the best practices for my use-case? What would be the disadvantages of directly invoking the second Lambda?
The advantage of using an SQS queue to capture errors is that it can store them in case you can't process them immediately. What if the reason your first function fails is that your database is down? If you directly invoke the second function, it will just fail as well. Storing the messages in SQS allows you to wait to process the errors until such time as your system is capable of processing them.