This is a simple python decorate for the aws serverless (lambda) functions to make it easy to add email notification (or other SNS handling) for errors and exceptions.
|
6 年 前 | |
---|---|---|
.gitignore | 6 年 前 | |
LICENSE | 6 年 前 | |
README.md | 6 年 前 | |
lambda_function.py | 6 年 前 |
This is a simple template you can add to your existing AWS Lambda python code so that it will email you details on your exceptions and errors.
You can use CloudWatch to alert on errors, but then you just know that something went wrong, not what went wrong.
I'm sure there are other ways to do this, but I didn't have luck finding them and getting the information I needed, so here's what I came up with.
This could generate a LOT of email. I am not responsible for your email administrator's wrath. You could always set up a different subscriber to the SNS topic instead of directly emailing.
This won't report syntax errors when loading the code. Make it a best practice
to run python3 -m py_compile lambda_function.py
before deploying to python.
For that matter, add some unit or doc tests.
It also won't catch errors with deployment of the lambda environment, which does happen from time to time.
It will also report errors even if a retry of the script succeeds. See AWS Lambda Retry Behavior for information on when it may automatically be retried.
Lastly, it won't catch issues with the SNS queue itself. If that isn't set up right, you won't get emails.
Please share it. I'd love to hear it it. I want to see:
Additionally, it needs to handle rates of thousands of executions per second.
lambda_handler
function.lambda_function.py
to your function and make it the new handler.