

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Amazon SES
<a name="automation-ref-ses"></a>

 AWS Systems Manager Automation 为 Amazon 简单电子邮件服务提供了预定义的运行手册。有关运行手册的更多信息，请参阅[使用运行手册](https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-documents.html)。有关如何查看运行手册内容的信息，请参阅 [查看运行手册内容](automation-runbook-reference.md#view-automation-json)。

**Topics**
+ [`AWSSupport-AnalyzeSESMessageSendingStatus`](awssupport-analyze-ses-message-sending-status.md)
+ [`AWSSupport-DeploySESSendingLogsToCloudWatchLogs`](automation-awssupport-deploysessendinglogstocloudwatchlogs.md)

# `AWSSupport-AnalyzeSESMessageSendingStatus`
<a name="awssupport-analyze-ses-message-sending-status"></a>

**说明**  
 `AWSSupport-AnalyzeSESMessageSendingStatus`自动化运行手册汇总了未送达电子邮件的电子邮件发送状态，并为您提供解决未送达原因的建议。该运行手册检索存储在亚马逊 SES 发布的亚马逊 CloudWatch 日志组中的亚马逊简单电子邮件服务 (Amazon SES) Semple Email SES 电子邮件发送事件。有关 Amazon SES 事件发布的详细信息，请参阅[使用亚马逊简单电子邮件服务监控事件发布](https://docs.aws.amazon.com/ses/latest/dg/monitor-using-event-publishing.html)。该运行手册还提供了电子邮件发送的摘要和时间表，以及可能影响未送达电子邮件的建议。你可以在每次执行的输出部分找到这些消息。请注意，此运行手册只能在部署事件存储之后对事件进行故障排除。

 **如何工作？** 

 运行手册执行以下步骤：
+ 检查同一 L CloudWatch ogs 组的并发自动化执行情况。
+ 分析与自动化参数 IDs 给出的消息对应的 Amazon SES 事件。
+ 将交付摘要输出到自动化执行的输出部分。

**重要**  
在执行本运行手册之前，您必须将已发布的 Amazon SES 事件存储到由自动化参数指定的 CloudWatch 日志组中。本运行手册仅分析存储在日志组中的 Amazon SES 事件。

 [运行此自动化（控制台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWSSupport-AnalyzeSESMessageSendingStatus) 

**文档类型**

自动化

**所有者**

Amazon

**平台**

Linux、macOS、Windows

**参数**

**所需的 IAM 权限**

`AutomationAssumeRole` 参数需要执行以下操作才能成功使用运行手册。
+ `logs:StartQuery`
+ `logs:GetQueryResults`
+ `ses:GetIdentityMailFromDomainAttributes`
+ `ses:GetSendQuota`
+ `ssm:DescribeAutomationExecutions`
+ `ssm:GetAutomationExecution`

 **说明** 

按照这些步骤对自动化进行配置：

1. [https://console.aws.amazon.com/systems-manager/documents/AWSSupport-AnalyzeSESMessageSendingStatus/description](https://console.aws.amazon.com/systems-manager/documents/AWSSupport-AnalyzeSESMessageSendingStatus/description)在 Systems Manager 的 “文档” 下导航至。

1. 选择 Execute automation（执行自动化）。

1. 对于输入参数，请输入以下内容：
   + **AutomationAssumeRole （可选）：**

     允许 Systems Manager Automation 代表您执行操作的 AWS AWS Identity and Access Management (IAM) 角色的亚马逊资源名称 (ARN)。如果未指定角色，Systems Manager Automation 将使用启动此运行手册的用户的权限。
   + **MessageIds （必填）**

     以逗号分隔您要分析 IDs 的亚马逊简单电子邮件服务事件的亚马逊简单电子邮件服务消息。
   + **CloudWatchLogsGroup （可选）**

     存储亚马逊简单电子邮件服务事件的 Amazon L CloudWatch ogs 组。默认日志组名称为 `/ses/sending\$1event\$1logs`。如果您想使用默认日志组以外的其他日志组，请在此字段中输入您的日志组名称。 “，
   + **QueryStartTime （可选）**

     事件分析的时间范围的开始时间。有效的时间格式为 ISO8601 （例如 `yyyy-mm-ddthh: mm: ss`、`1970-01-01T 00:00:00 `）。默认日期时间为 30 天前。
   + **QueryEndTime （可选）**

      事件分析的时间范围的结束时间。有效的时间格式为 ISO8601 （例如 `yyyy-mm-ddthh: mm: ss`、`1970-01-01T 00:00:00 `）。默认日期时间为当前时间。  
![\[管理控制台上的 “输入参数” 部分，其中显示了上述五个参数的文本框。\]](http://docs.aws.amazon.com/zh_cn/systems-manager-automation-runbooks/latest/userguide/images/awssupport-analyze-ses-message-sending-status_input_parameters.png)

1. 选择执行。

1. 自动化启动。

1. 文档将执行以下步骤：
   + **`CheckConcurrency:`**

     确保此运行手册只执行一次针对 Amazon CloudWatch Logs 组。如果 runbook 发现另一个针对同一日志组的执行，则会返回错误并结束。
   + **`AnalyzeSesEvents:`**

     分析存储在由自动化参数指定的亚马逊 CloudWatch 日志组中的亚马逊简单电子邮件服务事件。
   + **`OutputFailureReason:`**

     步骤失败时输出执行`AnalyzeSESMessageSendingStatus`步骤失败消息。

1. 完成后，请查看 “输出” 部分，了解执行的详细结果：
   + **对因退信而未送达的电子邮件进行分析的输出**

     由于退信而未到达目标邮箱的电子邮件的自动化执行输出。  
![\[收到来自目标电子邮件服务器的退回邮件的邮件 ID 的自动化执行输出示例。\]](http://docs.aws.amazon.com/zh_cn/systems-manager-automation-runbooks/latest/userguide/images/awssupport-analyze-ses-message-sending-status_outputs.png)

 **参考** 

Systems Manager Automation
+ [运行此自动化（控制台）](https://console.aws.amazon.com/systems-manager/documents/AWSSupport-AnalyzeSESMessageSendingStatus/description)
+ [运行自动化](https://docs.aws.amazon.com//systems-manager/latest/userguide/automation-working-executing.html)
+ [设置自动化](https://docs.aws.amazon.com//systems-manager/latest/userguide/automation-setup.html)
+ [支持自动化工作流登录页面](https://aws.amazon.com/premiumsupport/technology/saw/)

# `AWSSupport-DeploySESSendingLogsToCloudWatchLogs`
<a name="automation-awssupport-deploysessendinglogstocloudwatchlogs"></a>

 **描述** 

 ** AWSSupport-DeploySESSendingLogsToCloudWatchLogs 自动化运行手册可帮助配置亚马逊简单电子邮件服务 (Amazon SES) Service 将事件发布到 CloudWatch 亚马逊日志CloudWatch （日志）所需的基础设施。**本运行手册设置了捕获电子邮件发送事件并将其存储在 CloudWatch 日志中以进行监控和分析所需的组件。有关 Amazon SES 事件发布的更多信息，请参阅[使用 Amazon SES 事件发布监控电子邮件发送](https://docs.aws.amazon.com/ses/latest/dg/monitor-using-event-publishing.html)。

 当`ApproveDeployAnalyticEnvironment`参数设置为时`approve`，此运行手册会在您的 AWS 账户中创建新 AWS 资源。除非设置为，否则 CloudFormation 堆栈将在`SleepTime`参数中指定的时间之后自动删除`0`。

 **如何工作？** 

此运行手册执行以下操作：
+ 列出已为亚马逊简单通知服务 (Amazon SNS) Simple Notification Service 主题或传送流配置了事件目标的现有配置集。
+ 当`ApproveDeployAnalyticEnvironment`参数设置为时，创建 Amazon SES 事件发布到 CloudWatch 日志所需的基础设施`approve`。

当`ApproveDeployAnalyticEnvironment`参数设置为时`approve`，运行手册将创建以下资源：
+ 一个名为的 CloudFormation 堆栈`AWSSupport-SESSendingLogsToCloudWatchLogs`，其中包括：
  + 使用 AWS Key Management Service ()AWS KMS加密的 Amazon SNS 主题
  + Amazon Simple Queue Service（Amazon SQS）队列
  + AWS Lambda 用于处理电子邮件发送事件的函数
  + AWS Identity and Access Management (IAM) 执行角色，具有 Amazon SQS 和日志权限 CloudWatch 
  + CloudWatch 日志日志组
  + AWS KMS 加密密钥
  + 带有事件目标的 Amazon SES 配置集
+ 基础设施按以下流程处理电子邮件发送事件：Amazon SES 电子邮件发送事件 → Amazon SES 配置集 → 亚马逊 SNS 主题 → 亚马逊 SQS 队列 → Lambda 函数 → 日志 CloudWatch 
+ 提供`SesIdentity`参数时，将创建的配置集关联为指定 Amazon SES 身份的默认配置集。

 [运行此自动化（控制台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWSSupport-DeploySESSendingLogsToCloudWatchLogs) 

**文档类型**

自动化

**所有者**

Amazon

**平台**

/

**所需的 IAM 权限**

`AutomationAssumeRole` 参数需要执行以下操作才能成功使用运行手册。
+ `cloudformation:CreateStack`
+ `cloudformation:DeleteStack`
+ `cloudformation:DescribeStackEvents`
+ `cloudformation:DescribeStacks`
+ `iam:CreateRole`
+ `iam:AttachRolePolicy`
+ `iam:PassRole`
+ `kms:CreateKey`
+ `kms:CreateAlias`
+ `lambda:CreateFunction`
+ `lambda:AddPermission`
+ `logs:CreateLogGroup`
+ `logs:PutRetentionPolicy`
+ `ses:CreateConfigurationSet`
+ `ses:CreateConfigurationSetEventDestination`
+ `ses:ListConfigurationSets`
+ `ses:PutEmailIdentityConfigurationSetAttributes`
+ `sns:CreateTopic`
+ `sns:Subscribe`
+ `sqs:CreateQueue`
+ `sqs:SetQueueAttributes`
+ `ssm:DescribeAutomationExecutions`

策略示例：

```
{
       "Version": "2012-10-17",		 	 	 
       "Statement": [
           {
           "Effect": "Allow",
           "Action": [
               "cloudformation:CreateStack",
               "cloudformation:DeleteStack",
               "cloudformation:DescribeStackEvents",
               "cloudformation:DescribeStacks",
               "iam:CreateRole",
               "iam:AttachRolePolicy",
               "iam:PassRole",
               "kms:CreateKey",
               "kms:CreateAlias",
               "lambda:CreateFunction",
               "lambda:AddPermission",
               "logs:CreateLogGroup",
               "logs:PutRetentionPolicy",
               "ses:CreateConfigurationSet",
               "ses:CreateConfigurationSetEventDestination",
               "ses:ListConfigurationSets",
               "ses:PutEmailIdentityConfigurationSetAttributes",
               "sns:CreateTopic",
               "sns:Subscribe",
               "sqs:CreateQueue",
               "sqs:SetQueueAttributes",
               "ssm:DescribeAutomationExecutions"
           ],
           "Resource": "*"
           }
       ]
       }
```

 **说明** 

按照这些步骤对自动化进行配置：

1. [https://console.aws.amazon.com/systems-manager/documents/AWSSupport-DeploySESSendingLogsToCloudWatchLogs/description](https://console.aws.amazon.com/systems-manager/documents/AWSSupport-DeploySESSendingLogsToCloudWatchLogs/description)在 Systems Manager 的 “文档” 下导航至。

1. 选择 **Execute automation**（执行自动化）。

1. 对于输入参数，请输入以下内容：
   + **AutomationAssumeRole （可选）：**
     + 描述：（可选）允许 Systems Manager Automation 代表您执行操作的 IAM 角色的亚马逊资源名称 (ARN)。如果未指定角色，Systems Manager Automation 将使用启动此运行手册的用户的权限。
     + 类型：`AWS::IAM::Role::Arn`
   + **ApproveDeployAnalyticEnvironment （可选）：**
     + 描述：（可选）批准部署 Amazon SES 事件发布基础设施。输入`approve`以创建 CloudFormation 堆栈和相关资源。如果留空，则运行手册仅显示当前区域中包含或 Amazon SNS 事件目标的现有配置集。
     + 类型：`String`
     + 允许模式：`^$|^approve$`
     + 默认值：`""`
   + **SesIdentity （可选）：**
     + 描述：（可选）Amazon SES 身份（电子邮件地址或域），用于与新创建的配置集关联为默认配置集。这将覆盖为指定身份设置的任何现有默认配置。
     + 类型：`String`
     + 默认值：`""`
   + **CloudWatchLogGroupName （可选）：**
     + 描述：（可选）为存储 Amazon SES 电子邮件发送事件而创建的 CloudWatch 日志日志组的名称。
     + 类型：`String`
     + 允许模式：`^[0-9a-zA-Z_.#/\\-]{1,512}$`
     + 默认值：`/ses/sending_event_logs`
   + **口罩PIIData （可选）：**
     + 描述：（可选）指定是否在 CloudWatch 日志中屏蔽个人身份信息 (PII) 数据，例如目标电子邮件地址和电子邮件主题。设置`False`为可将此信息包含在日志中。
     + 类型：`String`
     + 允许的值：`[True, False]`
     + 默认值：`True`
   + **SleepTime （可选）：**
     + 描述：（可选）在自动删除 CloudFormation 堆栈之前等待的分钟数。默认值为 24 小时（1,440 分钟），最长为 7 天（10,080 分钟）。设置为`0`可防止自动删除。
     + 类型：`String`
     + 允许模式：`^(?:[0-9]|[1-9]\\d{1,3}|100[0-7][0-9])$`
     + 默认值：`1440`
   + **RetainCloudWatchLogsOnDeletion （可选）：**
     + 描述：（可选）指定在删除 CloudFormation 堆栈时是否保留 CloudWatch 日志日志组。设置`False`为可删除日志组和堆栈。
     + 类型：`String`
     + 允许的值：`[True, False]`
     + 默认值：`True`
   + **UniqueId （可选）：**
     + 说明：（可选）工作流程的唯一标识符。
     + 类型：`String`
     + 允许模式：`\\{\\{ automation:EXECUTION_ID \\}\\}|[a-zA-Z0-9-]+`
     + 默认值：`{{ automation:EXECUTION_ID }}`
     + ax 字符：`64`

1. 选择**执行**。

1. 自动化启动。

1. 文档将执行以下步骤：
   + **BranchOnValueOfParameterApproveDeployAnalyticEnvironment**

     根据`ApproveDeployAnalyticEnvironment`参数值确定是否部署 Amazon SES 事件发布基础设施。
   + **GetEligibleConfigurationSets**

     检索现有 Amazon SES 配置集，并识别那些为传送流或 Amazon SNS 主题配置了事件目标的配置集。
   + **CheckConcurrency**

     验证是否不存在任何现有堆栈，以及此 runbook 的其他并发执行是否正在创建相同的堆栈。
   + **DeploySesEventDestinations**

     创建包含 Amazon SES 事件发布基础设施的 CloudFormation 堆栈，包括亚马逊 SNS 主题、亚马逊 SQS 队列、Lambda 函数和日志组。 CloudWatch 
   + **RelateConfigurationSetAsDefaultConfigurationSet**

     将新创建的 Amazon SES 配置集关联为指定 Amazon SES 身份的默认配置集（如果提供）。
   + **SleepBeforeDeleteCloudFormationStack**

     等待 SleepTime 参数中指定的持续时间后再继续删除 CloudFormation 堆栈。
   + **DeleteCloudFormationStack**

     在指定的时间段后删除 CloudFormation 堆栈。

1. 完成后，请查看 “**输出**” 部分，了解执行的详细结果。

 **参考** 

Systems Manager Automation
+ [运行此自动化（控制台）](https://console.aws.amazon.com/systems-manager/documents/AWSSupport-DeploySESSendingLogsToCloudWatchLogs/description)
+ [运行自动化](https://docs.aws.amazon.com//systems-manager/latest/userguide/automation-working-executing.html)
+ [设置自动化](https://docs.aws.amazon.com//systems-manager/latest/userguide/automation-setup.html)
+ [支持自动化工作流登录页面](https://aws.amazon.com/premiumsupport/technology/saw/)