Create and manage rule sets
An ingress endpoint receives email for Mail Manager. After its traffic policy accepts a recipient, its
assigned rule set processes the email. A rule set contains ordered rules. Each rule can use
Conditions and Unless entries to select recipients, then run
ordered Actions.
Use this page to create and manage rule sets, and to assign a rule set to an ingress endpoint.
For condition properties, operators, and Unless behavior, see Rule conditions. For action
parameters, ordering, resources, and permissions, see Rule actions. After you assign a rule set, use Monitor and troubleshoot rule sets to confirm
successful processing and investigate individual messages.
Before you begin
Before you create a rule set, create any resources required by its actions. For example, an action can require an archive, SMTP relay, Amazon S3 bucket, Amazon SNS topic, or Lambda function. See Rule actions for each action's resources and permissions.
The IAM user or role that follows these procedures needs permission for the rule-set
operations it uses. These operations can include ses:CreateRuleSet,
ses:GetRuleSet, ses:ListRuleSets,
ses:UpdateRuleSet, and ses:DeleteRuleSet. Assigning a rule
set also requires ses:CreateIngressPoint or
ses:UpdateIngressPoint. When an action uses an IAM role, the user or
role that creates or updates the rule set also needs iam:PassRole
permission for that role.
Before you create an ingress endpoint, create both the rule set and the traffic policy that you will assign to it. For traffic policy instructions, see Traffic policies and policy statements.
A rule set can contain up to 40 rules. Each rule can contain up to 10
Conditions entries, up to 10 Unless entries, and from 1
through 10 Actions.
Create and manage rule sets in the SES console
To create a rule set and add rules
Sign in to the AWS Management Console and open the Amazon SES console at https://console.aws.amazon.com/ses/
. -
In the navigation pane, under Mail Manager, choose Rule sets.
-
Choose Create rule set.
-
Enter a rule-set name, and then choose Create rule set.
-
On the rule set's details page, choose Edit.
-
Choose Create new rule.
-
In Rule details, enter a rule name.
-
To add a
Conditionsentry, choose Add new condition, and then select a property, operator, and value. See Rule conditions for supported properties, operators, and values. -
To add an
Unlessentry, select EXCEPT in the case of:, and then choose Add new exception. AnUnlessmatch prevents the current rule's actions from running for the matching recipient. -
Choose Add new action, and then configure the action. See Rule actions for action parameters and required permissions.
-
To add another action, choose Add new action. Use the arrow controls to put the actions in execution order.
-
Repeat the preceding steps for each rule. Use the controls in the Reorder column to put the rules in execution order.
-
Choose Save rule set.
To update and reorder rules
-
On the Rule sets page, choose the rule-set name.
-
Choose Edit.
-
To add a rule, choose Create new rule.
-
To update a rule, select it and change its
Conditions,Unless, orActionsentries in Rule details. -
To remove a rule, select it and choose Delete.
-
Use the arrow controls to reorder rules or actions.
-
Choose Save rule set.
Assign a rule set to an ingress endpoint
When you create an ingress endpoint, select the rule set in Rule set. You must also select a traffic policy. For the complete procedure, see Creating and managing ingress points.
To change the rule set assigned to an existing ingress endpoint
-
In the navigation pane, under Mail Manager, choose Ingress endpoints.
-
Choose the ingress endpoint name.
-
Choose Edit rule set.
-
In Rule set, select the replacement rule set.
-
Choose Save changes.
You cannot delete a rule set while an ingress endpoint references it. First assign a different rule set to each ingress endpoint that references the rule set.
To delete a rule set
-
In the navigation pane, under Mail Manager, choose Rule sets.
-
Select the rule set and choose Delete.
-
In the Delete rule set dialog, enter
confirm. -
Choose Delete.
Create and manage rule sets with the AWS CLI
The following commands use rule set IDs
rs-0123456789abcdef01234567 and
rs-fedcba9876543210fedcba98, traffic policy ID
tp-0123456789abcdef01234567, and ingress endpoint ID
inp-0123456789abcdef01234567. Replace these IDs and the AWS Region
with your own values.
Create a rule set
CreateRuleSet requires a rule-set name and a Rules list.
The following command creates a rule set with one rule. The rule adds the
X-Route: orders header when a recipient ends with
@example.com, except for test@example.com:
PROMPT> aws mailmanager create-rule-set \ --regionus-east-1\ --rule-set-nameinbound-routing\ --rules '[{ "Name": "route-orders", "Conditions": [{ "StringExpression": { "Evaluate": {"Attribute": "RECIPIENT"}, "Operator": "ENDS_WITH", "Values": ["@example.com"] } }], "Unless": [{ "StringExpression": { "Evaluate": {"Attribute": "RECIPIENT"}, "Operator": "EQUALS", "Values": ["test@example.com"] } }], "Actions": [{ "AddHeader": { "HeaderName": "X-Route", "HeaderValue": "orders" } }] }]'
The response contains the RuleSetId. Use this ID to retrieve, update,
assign, or delete the rule set.
Update, add, remove, and reorder rules
In the following command, replace the AWS Region and rule set ID with your own
values. Run get-rule-set to retrieve the current rule list before you
replace it:
PROMPT> aws mailmanager get-rule-set \ --regionus-east-1\ --rule-set-idrs-0123456789abcdef01234567
When you include --rules in update-rule-set, the supplied
list replaces all current rules. Include every rule that the rule set must retain.
The position of each rule in the list controls rule order. The position of each
action in Actions controls action order.
In the following command, replace the AWS Region and rule set ID with your own values. The command renames the rule set and replaces its rules with the displayed order:
PROMPT> aws mailmanager update-rule-set \ --regionus-east-1\ --rule-set-idrs-0123456789abcdef01234567\ --rule-set-nameinbound-routing-v2\ --rules '[ { "Name": "route-priority-orders", "Conditions": [{ "StringExpression": { "Evaluate": {"Attribute": "RECIPIENT"}, "Operator": "EQUALS", "Values": ["priority-orders@example.com"] } }], "Actions": [ {"AddHeader": {"HeaderName": "X-Priority", "HeaderValue": "high"}}, {"AddHeader": {"HeaderName": "X-Route", "HeaderValue": "orders"}} ] }, { "Name": "route-orders", "Conditions": [{ "StringExpression": { "Evaluate": {"Attribute": "RECIPIENT"}, "Operator": "ENDS_WITH", "Values": ["@example.com"] } }], "Unless": [{ "StringExpression": { "Evaluate": {"Attribute": "RECIPIENT"}, "Operator": "EQUALS", "Values": ["test@example.com"] } }], "Actions": [ {"AddHeader": {"HeaderName": "X-Route", "HeaderValue": "orders"}} ] } ]'
To add a rule or action, add it to the complete list. To remove one, omit it from the complete list. To reorder rules or actions, change their positions in the corresponding lists.
Assign a rule set to an ingress endpoint
An ingress endpoint requires an existing rule set and traffic policy. In the following command, replace the AWS Region, ingress endpoint name, rule set ID, and traffic policy ID with your own values. The command creates an open ingress endpoint and assigns both resources:
PROMPT> aws mailmanager create-ingress-point \ --regionus-east-1\ --ingress-point-nameorders-ingress\ --type OPEN \ --rule-set-idrs-0123456789abcdef01234567\ --traffic-policy-idtp-0123456789abcdef01234567\ --tls-policy REQUIRED
For other ingress endpoint types and settings, see Ingress endpoints.
In the following command, replace the AWS Region, ingress endpoint ID, and replacement rule set ID with your own values. The command replaces the rule set assigned to an existing ingress endpoint. Other ingress endpoint properties remain unchanged:
PROMPT> aws mailmanager update-ingress-point \ --regionus-east-1\ --ingress-point-idinp-0123456789abcdef01234567\ --rule-set-idrs-fedcba9876543210fedcba98
Delete a rule set
Before you delete rs-0123456789abcdef01234567, assign a different
rule set to every ingress endpoint that references it. In the following commands, replace
the AWS Region and resource IDs with your own values. The commands replace the
assignment on one ingress endpoint and then delete the unassigned rule set:
PROMPT> aws mailmanager update-ingress-point \ --regionus-east-1\ --ingress-point-idinp-0123456789abcdef01234567\ --rule-set-idrs-fedcba9876543210fedcba98PROMPT> aws mailmanager delete-rule-set \ --regionus-east-1\ --rule-set-idrs-0123456789abcdef01234567