dattaprasad mundada
dattaprasad mundada

Reputation: 51

Can we attach SNS notification when any aws lambda function gets timed-out?

I need to send notification mail if my lambda function gets any error or got timed out. I had handled errors programmatically in function code but unable to notify when function gets timed out. I am ready with my SNS topic and all.

Can anyone please help regarding this.

Upvotes: 4

Views: 1397

Answers (2)

j-u-s-t-i-n
j-u-s-t-i-n

Reputation: 1452

Not sure on your use case, but you can check the time remaining, before the function times out using the context object getRemainingTimeInMillis function. Doing so would allow you to more gracefully handle timeouts than dropping to the DLQ for timeouts. Although, you could/should still put the DLQ in place for unexpected errors.

Upvotes: 0

franklinsijo
franklinsijo

Reputation: 18290

Yes, You can provide SNS as the DLQ(Dead Letter Queue) Resource for your asynchronous Lambda functions (where the event sources are not stream based).

On failures like timeout, resource constraints, endpoint access issues, the exception thrown by the lambda function will be sent to the configured DLQ.

Upvotes: 6

Related Questions