I have a machine that's reacting to commands from my cloud, in an AWS SQS queue. The machine reports status back using AWS SNS topic, which may activate Lambda functions that can do some stuff (i.e. database lookups etc.) and send a new command to the machine.
Sometimes things go wrong, or the machine sends invalid data due to user input etc. This will result in an exception being thrown in the Lambda functions.
Is it possible somehow, to make the SNS Trigger catch that exception from the Lambda, so I can handle it and make a uniformed way to send error messages back to the machine?
It's not possible with a vanilla SNS trigger. The trigger has no knowledge of what happens after it fires. The easiest solution is to modify your Lambda function to send a message to your machine during exception handling. Alternately, you can wrap your Lambda execution in a step function and handle errors that way.