(可选)设置 Amazon SNS 以接收关于 OpsItems 的通知 - Amazon Systems Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

(可选)设置 Amazon SNS 以接收关于 OpsItems 的通知

您可以将 OpsCenter 配置为在系统创建 OpsItem 或更新现有 OpsItem 时,向 Amazon Simple Notification Service(Amazon SNS)主题发送通知。

完成以下步骤以接收 OpsItems 的通知。

步骤 1:创建并订阅 Amazon SNS 主题

要接收通知,您必须创建并订阅 Amazon SNS 主题。有关更多信息,请参阅 Amazon Simple Notification Service Developer Guide 中的创建 Amazon SNS 主题订阅 Amazon SNS 主题

注意

如果您在多个 Amazon Web Services 区域 或账户中使用 OpsCenter,则必须在每个要接收 OpsItem 通知的区域或账户中创建并订阅 Amazon SNS 主题。

步骤 2:更新 Amazon SNS 访问策略

您必须将 Amazon SNS 主题与 OpsItems 关联。使用以下过程设置 Amazon SNS 访问策略,以便 Systems Manager 能将 OpsItems 通知发布到您在步骤 1 中创建的 Amazon SNS 主题。

  1. 访问 https://console.aws.amazon.com/sns/v3/home,登录 Amazon Web Services Management Console 并打开 Amazon SNS 控制台。

  2. 在导航窗格中,选择 Topics(主题)

  3. 选择您在“步骤 1”中创建的主题,然后选择编辑

  4. 展开 Access policy (访问策略)

  5. 将以下 Sid 数据块添加到现有策略。将每个示例资源占位符替换为您自己的信息。

    { "Sid": "Allow OpsCenter to publish to this topic", "Effect": "Allow", "Principal": { "Service": "ssm.amazonaws.com" }, "Action": "SNS:Publish", "Resource": "arn:aws:sns:region:account ID:topic name", // Account ID of the SNS topic owner "Condition": { "StringEquals": { "AWS:SourceAccount": "account ID" // Account ID of the OpsItem owner } } }
    注意

    使用 aws:SourceAccount 全局条件键来防止混淆代理场景。要使用此条件键,请将值设置为 OpsItem 所有者的账户 ID。有关更多信息,请参阅《IAM 用户指南》中的混淆代理

  6. 选择 Save changes(保存更改)

现在,当创建或更新 OpsItems 时,系统会向 Amazon SNS 主题发送通知。

重要

如果使用 Amazon Key Management Service(Amazon KMS)服务器端加密密钥配置 Amazon SNS 主题,则必须完成步骤 3。否则,可以跳过“步骤 3”。

步骤 3:更新 Amazon KMS 访问策略

如果您为 Amazon SNS 主题启用了 Amazon KMS 服务器端加密,则还必须更新您在配置主题时选择的 Amazon KMS key 的访问策略。使用以下过程更新访问策略,以便 Systems Manager 能将 OpsItem 通知发布到您在“步骤 1”中创建的 Amazon SNS 主题。

注意

OpsCenter 不支持将 OpsItems 发布到使用 Amazon 托管式密钥 配置的 Amazon SNS 主题。

  1. https://console.aws.amazon.com/kms 打开 Amazon KMS 控制台。

  2. 要更改 Amazon Web Services 区域,请使用页面右上角的区域选择器。

  3. 在导航窗格中,选择客户托管密钥

  4. 选择您在创建主题时选择的 KMS 密钥的 ID。

  5. Key Policy (密钥策略) 部分中,选择 Switch to policy view (切换到策略视图)

  6. 选择编辑

  7. 将以下 Sid 数据块添加到现有策略。将每个示例资源占位符替换为您自己的信息。

    { "Sid": "Allow OpsItems to decrypt the key", "Effect": "Allow", "Principal": { "Service": "ssm.amazonaws.com" }, "Action": ["kms:Decrypt", "kms:GenerateDataKey*"], "Resource": "arn:aws:kms:region:account ID:key/key ID" }

    在下面的示例中,在第 14 行输入新块。

    
                                编辑 Amazon SNS 主题的 Amazon KMS 访问策略。
  8. 选择 Save changes(保存更改)

步骤 4:打开默认 OpsItems 规则以针对新的 OpsItems 发送通知

未使用 Amazon 资源名称(ARN)针对 Amazon SNS 通知配置 Amazon EventBridge 中的默认 OpsItems 规则。使用以下过程编辑 EventBridge 中的规则并输入 notifications 数据块。

将通知块添加到默认 OpsItem 规则
  1. 访问 https://console.aws.amazon.com/systems-manager/,打开 Amazon Systems Manager 控制台。

  2. 在导航窗格中,选择 OpsCenter

  3. 选择 OpsItems 选项卡,然后选择 Configure sources (配置源)

  4. 选择您要使用 notifications 块配置的源规则的名称,如以下示例所示:

    
                                选择 Amazon EventBridge 规则以添加 Amazon SNS 通知块。

    该规则将在 Amazon EventBridge 中打开。

  5. 在规则详细信息页面的 Targets(目标)选项卡上,选择 Edit(编辑)。

  6. Additional settings(其他设置)部分,选择 Configure input transformer(配置输入转换器)。

  7. 模板框中,添加一个具有以下格式的 notifications 块:

    "notifications":[{"arn":"arn:aws:sns:region:account ID:topic name"}],

    以下为示例。

    "notifications":[{"arn":"arn:aws:sns:us-west-2:1234567890:MySNSTopic"}],

    resources 块之前输入通知块,如以下美国西部(俄勒冈州)(us-west-2)区域示例所示。

    { "title": "EBS snapshot copy failed", "description": "CloudWatch Event Rule SSMOpsItems-EBS-snapshot-copy-failed was triggered. Your EBS snapshot copy has failed. See below for more details.", "category": "Availability", "severity": "2", "source": "EC2", "notifications": [{ "arn": "arn:aws:sns:us-west-2:1234567890:MySNSTopic" }], "resources": <resources>, "operationalData": { "/aws/dedup": { "type": "SearchableString", "value": "{\"dedupString\":\"SSMOpsItems-EBS-snapshot-copy-failed\"}" }, "/aws/automations": { "value": "[ { \"automationType\": \"AWS:SSM:Automation\", \"automationId\": \"AWS-CopySnapshot\" } ]" }, "failure-cause": { "value": <failure - cause> }, "source": { "value": <source> }, "start-time": { "value": <start - time> }, "end-time": { "value": <end - time> } } }
  8. 选择确认

  9. 选择下一步

  10. 选择下一步

  11. 选择更新规则

当系统下次为默认规则创建 OpsItem 时,系统会向 Amazon SNS 主题发布通知。