Reputation: 5104
I have an AWS Lambda function that converts an html document to a pdf document whenever a new document is uploaded to S3. Working great.
Once the pdf has been generated, my application code (which is a traditional server backed web service) needs to send an email to the user with a link to the pdf file. I can think of a few ways to handle this:
In reality all of these will work, but I am curious if there is a suggested 'best practice' for handling AWS lambdas that are triggered asynchronously like this, rather then being directly triggered.
Upvotes: 1
Views: 1314
Reputation: 625
Take a look at Lambda Dead Letter Queues.
By default, a failed Lambda function invoked asynchronously is retried twice, and then the event is discarded. Using Dead Letter Queues (DLQ), you can indicate to Lambda that unprocessed events should be sent to an Amazon SQS queue or Amazon SNS topic instead, where you can take further action.
You configure a DLQ by specifying a target Amazon Resource Name (ARN) on a Lambda function's DeadLetterConfig parameter of an Amazon SNS topic or an Amazon SQS queue where you want the event payload delivered, as shown in the following code. For more information about creating an Amazon SNS topic, see Create an SNS Topic. For more information about creating an Amazon SQS queue, see Tutorial: Creating an Amazon SQS Queue.
Upvotes: 2