Amazon Simple Email Service Construct Library¶---
This module is part of the AWS Cloud Development Kit project.
Create a receipt rule set with rules and actions (actions can be found in the
import aws_cdk.aws_s3 as s3 import aws_cdk.aws_ses_actions as actions bucket = s3.Bucket(self, "Bucket") topic = sns.Topic(self, "Topic") ses.ReceiptRuleSet(self, "RuleSet", rules=[ses.ReceiptRuleOptions( recipients=["firstname.lastname@example.org"], actions=[ actions.AddHeader( name="X-Special-Header", value="aws" ), actions.S3( bucket=bucket, object_key_prefix="emails/", topic=topic ) ] ), ses.ReceiptRuleOptions( recipients=["aws.com"], actions=[ actions.Sns( topic=topic ) ] ) ] )
Alternatively, rules can be added to a rule set:
rule_set = ses.ReceiptRuleSet(self, "RuleSet") aws_rule = rule_set.add_rule("Aws", recipients=["aws.com"] )
And actions to rules:
import aws_cdk.aws_ses_actions as actions # aws_rule: ses.ReceiptRule # topic: sns.Topic aws_rule.add_action(actions.Sns( topic=topic ))
addRule, the new rule is added after the last added rule unless
after is specified.
Create a receipt filter:
ses.ReceiptFilter(self, "Filter", ip="184.108.40.206/16" )
An allow list filter is also available:
ses.AllowListReceiptFilter(self, "AllowList", ips=["10.0.0.0/16", "220.127.116.11/16" ] )
This will first create a block all filter and then create allow filters for the listed ip addresses.