RuleSet
Source:
src/AWS/MailManager/RuleSet.ts
An SES Mail Manager rule set — the ordered rules an ingress point applies to incoming email (drop, archive, write to S3, deliver, bounce, invoke Lambda, …).
All aspects (name, rules, tags) update in place.
Creating Rule Sets
Section titled “Creating Rule Sets”Drop Everything
import * as MailManager from "alchemy/AWS/MailManager";
const ruleSet = yield* MailManager.RuleSet("Inbound", { rules: [{ Name: "DropAll", Actions: [{ Drop: {} }] }],});Conditional Archive
const ruleSet = yield* MailManager.RuleSet("Inbound", { rules: [ { Name: "ArchiveLarge", Conditions: [ { NumberExpression: { Evaluate: { Attribute: "MESSAGE_SIZE" }, Operator: "GREATER_THAN", Value: 1024, }, }, ], Actions: [{ Archive: { TargetArchive: archive.archiveId } }], }, ],});Wiring to an Ingress Point
Section titled “Wiring to an Ingress Point”const ingress = yield* MailManager.IngressPoint("Smtp", { type: "OPEN", ruleSetId: ruleSet.ruleSetId, trafficPolicyId: trafficPolicy.trafficPolicyId,});Delivering Email Events to Compute
Section titled “Delivering Email Events to Compute”// Mail Manager has no EventBridge events or event-source mapping — email// events reach compute through rule actions: InvokeLambda (direct),// PublishToSns (SNS event source), or WriteToS3 (S3 event source). The// role must be assumable by ses.amazonaws.com with lambda:InvokeFunction.const ruleSet = yield* MailManager.RuleSet("Inbound", { rules: [ { Name: "NotifyOnMail", Actions: [ { InvokeLambda: { FunctionArn: fn.functionArn, InvocationType: "EVENT", RoleArn: invokeRole.roleArn, }, }, ], }, ],});