You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: IDEA.md
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,36 +6,35 @@ This is intended to be a framework that can be used by client code to define the
6
6
7
7
## Components
8
8
9
-
1.**Scheduled Lambda Functions**: The goal here is that the client can provide their own lambda function (as a container image) and, from that, we will run it on a schedule defined by the client. The lambda function needs to know 1 or more SNS topics to which it will publish messages when it runs; different "types" of messages can go to different SNS topics, which will then be subscribed to by different notification channels. This will include the lambda execution role and the scheduled events.
10
-
2.**SNS Topics**: These will be manually created by the client code, but ARNs might be needed to give the lambda permissions to publish.
11
-
3.**Notification Channels**: We will provide modules for different notification channels (e.g., email via SES, SMS via Twilio, etc.). Each notification module owns the SNS->SQS->Lambda wiring: it provisions the FIFO SQS queue/subscription used for deduplication and triggers its handler; the user should not create that queue manually. Each channel ships its own container image (build or republish) that renders a Jinja2 template and delivers via its notifier.
9
+
1.**Scheduled Lambda Functions**: The goal here is that the client can provide their own lambda function (as a container image) and, from that, we will run it on a schedule defined by the client. The lambda function will publish to a single SNS topic and set a `result_type` (or similar) message attribute; notification channels will filter on one or more types. This will include the lambda execution role and the scheduled events.
10
+
2.**SNS Topic**: A single topic is manually created by the client code; its ARN is needed to give the lambda permissions to publish. Filtering is done via subscription filter policies, not separate topics.
11
+
3.**Notification Channels**: We will provide modules for different notification channels (e.g., email via SES, SMS via Twilio, etc.). Each notification module owns the SNS->SQS->Lambda wiring: it provisions the FIFO SQS queue/subscription used for deduplication and triggers its handler, with an SNS filter policy on the result type(s); the user should not create that queue manually. Each channel ships its own container image (build or republish) that renders a Jinja2 template and delivers via its notifier.
12
12
4.**Lambda Image Utilities**: In addition to republishing an existing Lambda container, we will provide a module to build an image from a local directory containing a Dockerfile and publish it to ECR for use by the scheduled-lambda module.
13
13
5.**Python Runtime Library**: Provide reusable Python code in `src/cloud_cron/` that makes authoring custom scheduled lambdas easy (task base class, SNS dispatch helpers, and ergonomic handler wiring). This includes a template provider abstraction so notification handlers can source templates from env vars, URLs, or S3.
14
14
15
15
16
16
The goal is that the user will need to:
17
17
18
-
1. Write a lambda function that publishes to the desired SNS topics (provided as envionment variables).
18
+
1. Write a lambda function that publishes to the shared SNS topic and sets a `result_type` message attribute (provided as an environment variable or constant).
19
19
2. Write a small terraform module that looks something like:
(There may be additional parameters needed, but this is the general idea.)
49
48
49
+
Notes on the single-topic approach:
50
+
- It simplifies wiring and allows channels to subscribe to multiple result types via filter policies.
51
+
- It reduces per-type IAM/topic configuration, but also means topic-level settings (KMS, delivery policy, metrics) are shared.
52
+
50
53
## Additional convenience
51
54
52
55
We should also provide a module that allows us to take an externally-defined lambda and redeploy it in a local environment. The idea is that the lambdas users use are served from their own accounts, and are copies of our official release lambdas.
Copy file name to clipboardExpand all lines: PLAN.md
+26-2Lines changed: 26 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,12 +27,36 @@
27
27
-[x] Example touchpoint: allow `examples/basic` to build/push a simple placeholder Lambda image from a local Dockerfile as an alternative to the republish module.
-[x] Create resources: IAM role/policy (CloudWatch Logs + `sns:Publish` to provided ARN), Lambda from container image, EventBridge rule/target/permission.
32
32
-[x] Outputs: Lambda ARN, execution role ARN, log group name, schedule rule name.
33
33
-[x] Docs: README with usage matching IDEA example.
34
34
-[x] Example touchpoint: scaffold `examples/basic` with this module + stub SNS topic(s) and the container image outputs from Phase 1; `terraform validate/plan` should pass to prove schedule wiring.
35
35
36
+
## Phase 2.5: Consolidate result routing into a single SNS topic
37
+
38
+
Overview: replace per-result-type topics with one shared SNS topic and use message attributes + subscription filter policies to route results to notification channels.
39
+
40
+
Success criteria:
41
+
42
+
- Scheduled lambdas publish to one topic and set a `result_type` message attribute.
43
+
- Notification modules accept `result_types` (list) and apply SNS filter policies to their subscriptions.
44
+
- Examples and docs reflect the single-topic pattern.
45
+
46
+
Decisions and motivations:
47
+
48
+
- Use SNS filter policies to reduce infrastructure and make multi-type subscriptions easy.
49
+
- Keep result types as message attributes to avoid changing payload shapes or handler code.
50
+
51
+
To-do:
52
+
53
+
-[x] Update `modules/scheduled-lambda` to accept `sns_topic_arn` (single) and adjust IAM to `sns:Publish` on that ARN.
54
+
-[x] Update notification plumbing module to accept `result_types` and apply SNS filter policy on the subscription.
55
+
-[x] Update existing per-channel modules to pass through `result_types` and document the attribute name.
56
+
-[x] Update `src/cloud_cron/` helpers to publish with a `result_type` attribute and validate allowed types.
57
+
-[x] Update `examples/basic` to use one topic and a single `result_types` subscription.
58
+
-[x] Update module READMEs and `IDEA.md` usage examples to match the new wiring.
59
+
36
60
## Phase 3: Python runtime library for custom lambdas (`src/cloud_cron/`)
37
61
38
62
Overview: turn the existing Python helpers into a reusable, testable library that makes it easy for users to author scheduled lambdas while keeping SNS wiring and logging consistent. This package will also host shared notification handler code (under `src/cloud_cron/notifications/`), while deployment/container wiring remains in Terraform modules.
0 commit comments