【发布时间】:2018-04-12 02:24:24
【问题描述】:
我试图弄清楚如何使用 CloudFormation 在 AWS 中自动创建多个云资源。
现在我需要包括创建 SES(简单电子邮件服务)域,但找不到文档,但我已经检查过:
AWS 是否支持 CloudFormation 中的 SES?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation amazon-ses
我试图弄清楚如何使用 CloudFormation 在 AWS 中自动创建多个云资源。
现在我需要包括创建 SES(简单电子邮件服务)域,但找不到文档,但我已经检查过:
AWS 是否支持 CloudFormation 中的 SES?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation amazon-ses
CloudFormation 提供了几个内置的Amazon SES resource types,但截至 2020 年仍然缺少许多人需要的:域和电子邮件验证。
幸运的是,CloudFormation 能够定义您自己的custom resource types。我已经构建了 Custom::SES_Domain 和 Custom::SES_EmailIdentity 资源,这些资源旨在与其他 CloudFormation 资源配合使用。在这里获取它们: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 用于控制几个常见的 SES 域选项,并公开 attributes 输入您的 CloudFormation DNS 资源:如上所示的标准 AWS::Route53::RecordSetGroup 资源,或通过区域文件条目的其他(外部)DNS 提供程序.
【讨论】:
很遗憾,目前不支持此功能,但谁知道 Re:Invent 2017 即将到来,,,
Question asked on AWS Developer Forum
可以通过创建自定义函数,一些关于 SES 和 cloudformation 的blog。
【讨论】:
虽然目前不支持 AWS Cloudformation,但请使用 AWS 开发工具包(例如 Node SDK)来预置所需的 SES 资源。
将自定义代码与 AWS 开发工具包和 AWS CLI 命令与 CloudFormation 结合使用来预置资源 AWS 是一种常见的做法,因为每种方法都可能是优势,具体取决于参数、资源数量、重复等。
【讨论】:
这是SES Resource Types supported by CloudFormation的当前列表:
AWS::SES::ConfigurationSet
AWS::SES::ConfigurationSetEventDestination
AWS::SES::ReceiptFilter
AWS::SES::ReceiptRule
AWS::SES::ReceiptRuleSet
AWS::SES::模板
【讨论】:
不支持。但是,你可以让它由 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
【讨论】: