Email notification channel#13
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13 +/- ##
==========================================
- Coverage 98.39% 98.28% -0.12%
==========================================
Files 8 10 +2
Lines 312 408 +96
==========================================
+ Hits 307 401 +94
- Misses 5 7 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
We can add this in later if needed; don't want to add it to maintenance yet.
Note that email addresses (to, from, reply_to) need config and aren't included here.
There was a problem hiding this comment.
Pull request overview
This PR adds email notification functionality via AWS SES to the cloud-cron framework. It introduces a new notification channel that renders subject, text, and HTML templates using Jinja2 and sends emails through SES.
Changes:
- Added
EmailNotificationHandlerPython class for SES email delivery with multi-template rendering - Created Terraform module
modules/email-notificationfor infrastructure provisioning - Integrated email notifications into the
examples/basicexample with template files
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/cloud_cron/notifications/email_handler.py | New handler class that renders three templates (subject/text/html) and sends via SES |
| tests/notifications/test_email_handler.py | Unit tests for email handler with fake SES client |
| src/cloud_cron/notifications/init.py | Export EmailNotificationHandler in public API |
| modules/email-notification/main.tf | Terraform module creating Lambda, IAM roles/policies, and SQS wiring |
| modules/email-notification/variables.tf | Input variables for sender, recipients, templates, and Lambda config |
| modules/email-notification/outputs.tf | Outputs for Lambda ARN, queue ARN/URL, and subscription ARN |
| modules/email-notification/README.md | Documentation for the email notification module |
| examples/basic/main.tf | Integration of email notification module in example |
| examples/basic/variables.tf | New variables for email sender, recipients, and reply-to |
| examples/basic/email-notifier/handler.py | Lambda handler entry point using EmailNotificationHandler |
| examples/basic/email-notifier/Dockerfile | Container image definition for email notifier Lambda |
| examples/basic/templates/email-*.txt/.html | Example email templates for subject, text, and HTML bodies |
| PLAN.md | Updated Phase 4.2 task descriptions to reflect implementation approach |
| IDEA.md | Clarified email handler design in architecture documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
First, the base class is now named RenderedTemplateNotificationHandler, because this is specific to cases where we render templates locally. Second, we always, in principle, work with multiple templates, stored in a dict. The keys to this dict are usually set in `__init__`, and only need to be known by the class's `__init__` and the class's `notify`. This allows us to handle either a single template, as with the print notifier, or multiple, as with the email notifier.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ethanholz
left a comment
There was a problem hiding this comment.
This looks good, especially if we are going to split this off into a PyPI package.
This PR will add email (via SES) as a notification channel.
modules/email_notificationto handle the infrastructure (lambda function, IAM including SES permissions, SQS plumbing)examples/basicexamples/basicin actual deploymentUpdates:
This involved implementing a significant refactor of the base class in 2ac5070. See commit message on that for details.
Also tried to implement some potentially better error handling for SQS errors. That work starts in 2c4fc89 and following. I'm not yet sure how that will work in practice; I think I need to see the system at work before I can tell whether that is needed.