I've set up a Lambda like so:
exports.handler = async (event) => {
throw new Error('I AM SAD');
};
It can be invoked both by an SNS topic and from API Gateway.
I've also setup an SNS topic with two subscriptions; one sends messages directly to the Lambda (using Lamba protocol); the other sends it through API Gateway (HTTPS). I would like SNS to retry sending the message when the lambda fails. But it only seems work through API Gateway. When the Lambda is invoked directly, SNS only tries once (and reports SUCCESS).
I know there is some sort of retry policy even for SNS -> Lambda but when does this trigger? For SNS -> HTTP it seems to trigger when it receives a HTTP error code.
From Amazon SNS Dead-Letter Queues - Amazon Simple Notification Service:
Client-side errors can happen when Amazon SNS has stale subscription metadata. These errors commonly occur when an owner deletes the endpoint (for example, a Lambda function subscribed to an Amazon SNS topic) or when an owner changes the policy attached to the subscribed endpoint in a way that prevents Amazon SNS from delivering messages to the endpoint. Amazon SNS doesn't retry the message delivery that fails as a result of a client-side error.
Is a failed lambda (as the one above) considered a client-side error? Can I force a server-side error?