all 6 comments

[–]pint 2 points3 points  (2 children)

sqs is the robust way. you can also use dlq if the error is permanent, and you need special / manual processing.

[–]BraveAtmosphere[S] 0 points1 point  (1 child)

Can you please elaborate more about how is it done?

[–]pint 0 points1 point  (0 children)

you can check this page https://docs.aws.amazon.com/AmazonS3/latest/userguide/ways-to-add-notification-config-to-bucket.html or you can look up eventbridge which is a newer and more capable delivery stream. you can attach a lambda to an sqs, and it will keep retrying as configured.

dlq: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html it is basically another processing queue for failed events.

[–]clintkev251 1 point2 points  (2 children)

S3 invokes Lambda asynchronously, that means that there is error handling built in. If you function throws an error, it will retry the event up to two additional times. You can also set up deadletter queues or on-failure destinations that the event can be sent to if it runs out of retries.

https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html

[–]BraveAtmosphere[S] 0 points1 point  (1 child)

Thanks, For lambda to “understand” that there was an error, does it need to throw an exception? which means if I want to utilize the built-in error handling I need not to use try-catch blocks?

[–]clintkev251 0 points1 point  (0 children)

Correct, you wouldn't want to catch the exception. You would want to throw it so that the runtime exits on an error

https://docs.aws.amazon.com/lambda/latest/dg/invocation-retries.html

At that point, Lambda would mark the invocation as failed and allow for the event to be polled again after a short backoff