1

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:

  1. Just assume the pdf conversion worked and trigger the email naively
  2. Send a webhook from the lambda function to my application code when the conversion happens
  3. In the background job check for the existence of the pdf before sending the email

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.

2
  • Step Functions is one approach: aws.amazon.com/step-functions Commented Mar 14, 2018 at 18:13
  • Your lambda function could invoke a backend rest api call with file path details once s3 upload is done. Commented Mar 14, 2018 at 18:19

1 Answer 1

2

Take a look at Lambda Dead Letter Queues.

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.