Skip to content
GitHubXDiscord

ReceiptRuleSet

The ReceiptRuleSet resource allows you to manage AWS SES ReceiptRuleSets and their associated rules for handling incoming email.

Create a basic receipt rule set with a specified name:

import AWS from "alchemy/aws/control";
const receiptRuleSet = await AWS.SES.ReceiptRuleSet("myReceiptRuleSet", {
RuleSetName: "MyReceiptRuleSet",
});

Configure a receipt rule set with an option to adopt an existing resource:

const existingReceiptRuleSet = await AWS.SES.ReceiptRuleSet("existingReceiptRuleSet", {
RuleSetName: "ExistingReceiptRuleSet",
adopt: true // Adopts the existing receipt rule set instead of failing
});

Create a receipt rule set and add rules for processing incoming emails:

const receiptRuleSetWithRules = await AWS.SES.ReceiptRuleSet("ruleSetWithRules", {
RuleSetName: "RuleSetWithEmailProcessing",
adopt: true
});
// Assume you have a method to add rules to the rule set
await addEmailProcessingRule(receiptRuleSetWithRules, {
ruleName: "MyEmailProcessingRule",
recipients: ["user@example.com"],
actions: [
{
type: "S3",
bucketName: "my-email-bucket",
objectKeyPrefix: "emails/"
},
{
type: "SNS",
topicArn: "arn:aws:sns:us-west-2:123456789012:MySNSTopic"
}
],
scanEnabled: true
});

This example demonstrates how to add rules to the receipt rule set for processing incoming emails, including storing them in an S3 bucket and notifying via SNS.