AWS 是否支持 CloudFormation 中的 SES?
Do AWS support SES in CloudFormation?
我正在尝试弄清楚如何使用 CloudFormation 在 AWS 中自动创建多个云资源。
现在我需要包括创建 SES(简单电子邮件服务)域,但找不到文档,但我已经检查过:
AWS 是否支持 CloudFormation 中的 SES?
遗憾的是目前不支持,但谁知道Re:Invent2017年就要到了,
Question asked on AWS Developer Forum
可以通过创建自定义函数来实现,一些 blog 关于 SES 和 cloudformation。
虽然目前不支持 AWS Cloudformation,但使用 AWS SDK(例如 Node SDK)来配置所需的 SES 资源。
将自定义代码与 AWS 开发工具包和 AWS CLI 命令结合使用 CloudFormation 来配置资源 AWS 是一种常见的做法,因为根据参数、资源数量、重复次数等,每种方法都可以发挥优势
不支持。但是,你可以让它由 lambda 处理。
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: >-
A simple email example
Resources:
FunctionEmailHandler:
Type: 'AWS::Serverless::Function'
Properties:
Handler: email.handler
Runtime: nodejs6.10
CodeUri: ..
Description: >-
...
Tags:
App: your app
MemorySize: 128
Timeout: 10
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 's3:GetObject'
Resource: '*'
LambdaInvokePermission:
Type: "AWS::Lambda::Permission"
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !GetAtt FunctionEmailHandler.Arn
Principal: ses.amazonaws.com
SESEmailRecievedRule:
Type: "AWS::SES::ReceiptRule"
Properties:
RuleSetName: your default rule set name
After: store-email-to-s3
Rule:
Name: email-recieved-rule
Enabled: true
Actions:
- LambdaAction:
FunctionArn: !GetAtt FunctionEmailHandler.Arn
InvocationType: Event
CloudFormation 提供了几个内置的Amazon SES resource types,但是截至2018 2020 2022 仍然缺少很多人需要:域和电子邮件验证。
幸运的是,CloudFormation 能够定义您自己的 custom resource types. I've built Custom::SES_Domain
and Custom::SES_EmailIdentity
resources that are designed to play well with other CloudFormation resources. Get them here: https://github.com/medmunds/aws-cfn-ses-domain。
将自定义 CfnSESResources
拉入模板后,您可以像这样验证 SES 域:
Resources:
# Provision a domain with Amazon SES:
MySESDomain:
Type: Custom::SES_Domain
Properties:
ServiceToken: !GetAtt CfnSESResources.Outputs.CustomDomainIdentityArn
Domain: "example.com"
EnableSend: true
EnableReceive: false
# Then add all required DNS records for SES verification and usage:
MyRoute53RecordsForSES:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: "example.com."
RecordSets: !GetAtt MySESDomain.Route53RecordSets
完整说明在存储库中。 Custom::SES_Domain
有 properties for controlling several common SES domain options, and exposes attributes 提供给您的 CloudFormation DNS 资源:如上所示的标准 AWS::Route53::RecordSetGroup
资源,或通过区域文件条目的其他(外部)DNS 提供商。
这是SES Resource Types supported by CloudFormation的当前列表:
AWS::SES::ConfigurationSet
AWS::SES::ConfigurationSetEventDestination
AWS::SES::ReceiptFilter
AWS::SES::ReceiptRule
AWS::SES::ReceiptRuleSet
AWS::SES::Template
我正在尝试弄清楚如何使用 CloudFormation 在 AWS 中自动创建多个云资源。
现在我需要包括创建 SES(简单电子邮件服务)域,但找不到文档,但我已经检查过:
AWS 是否支持 CloudFormation 中的 SES?
遗憾的是目前不支持,但谁知道Re:Invent2017年就要到了,
Question asked on AWS Developer Forum
可以通过创建自定义函数来实现,一些 blog 关于 SES 和 cloudformation。
虽然目前不支持 AWS Cloudformation,但使用 AWS SDK(例如 Node SDK)来配置所需的 SES 资源。
将自定义代码与 AWS 开发工具包和 AWS CLI 命令结合使用 CloudFormation 来配置资源 AWS 是一种常见的做法,因为根据参数、资源数量、重复次数等,每种方法都可以发挥优势
不支持。但是,你可以让它由 lambda 处理。
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: >-
A simple email example
Resources:
FunctionEmailHandler:
Type: 'AWS::Serverless::Function'
Properties:
Handler: email.handler
Runtime: nodejs6.10
CodeUri: ..
Description: >-
...
Tags:
App: your app
MemorySize: 128
Timeout: 10
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 's3:GetObject'
Resource: '*'
LambdaInvokePermission:
Type: "AWS::Lambda::Permission"
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !GetAtt FunctionEmailHandler.Arn
Principal: ses.amazonaws.com
SESEmailRecievedRule:
Type: "AWS::SES::ReceiptRule"
Properties:
RuleSetName: your default rule set name
After: store-email-to-s3
Rule:
Name: email-recieved-rule
Enabled: true
Actions:
- LambdaAction:
FunctionArn: !GetAtt FunctionEmailHandler.Arn
InvocationType: Event
CloudFormation 提供了几个内置的Amazon SES resource types,但是截至2018 2020 2022 仍然缺少很多人需要:域和电子邮件验证。
幸运的是,CloudFormation 能够定义您自己的 custom resource types. I've built Custom::SES_Domain
and Custom::SES_EmailIdentity
resources that are designed to play well with other CloudFormation resources. Get them here: https://github.com/medmunds/aws-cfn-ses-domain。
将自定义 CfnSESResources
拉入模板后,您可以像这样验证 SES 域:
Resources:
# Provision a domain with Amazon SES:
MySESDomain:
Type: Custom::SES_Domain
Properties:
ServiceToken: !GetAtt CfnSESResources.Outputs.CustomDomainIdentityArn
Domain: "example.com"
EnableSend: true
EnableReceive: false
# Then add all required DNS records for SES verification and usage:
MyRoute53RecordsForSES:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: "example.com."
RecordSets: !GetAtt MySESDomain.Route53RecordSets
完整说明在存储库中。 Custom::SES_Domain
有 properties for controlling several common SES domain options, and exposes attributes 提供给您的 CloudFormation DNS 资源:如上所示的标准 AWS::Route53::RecordSetGroup
资源,或通过区域文件条目的其他(外部)DNS 提供商。
这是SES Resource Types supported by CloudFormation的当前列表:
AWS::SES::ConfigurationSet
AWS::SES::ConfigurationSetEventDestination
AWS::SES::ReceiptFilter
AWS::SES::ReceiptRule
AWS::SES::ReceiptRuleSet
AWS::SES::Template