为 Automation 创建 Webhook 集成 - Amazon Systems Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

为 Automation 创建 Webhook 集成

要在自动化期间使用 Webhooks 发送消息,请创建集成。可以在自动化过程中使用您的运行手册中的 aws:invokeWebhook 操作调用集成。如果尚未创建 Webhook,请参阅 为集成创建 Webhooks。要了解有关 aws:invokeWebhook 操作的更多信息,请参阅 aws:invokeWebhook – 调用 Automation Webhook 集成

如以下程序所示,您可以使用 Systems Manager Automation 控制台或您的首选命令行工具来创建集成。

创建集成(控制台)

要为 Automation 创建集成(控制台)
  1. 访问 https://console.aws.amazon.com/systems-manager/,打开 Amazon Systems Manager 控制台。

  2. 在导航窗格中,选择 自动化

  3. 请选择 Integrations(集成)选项卡。

  4. 请选择 Add integration(添加集成),然后选择 Webhook

  5. 请输入要为集成包括的所需值和任何可选值。

  6. 请选择 Add(添加)来创建集成。

创建集成(命令行)

要使用命令行工具创建集成,您必须为集成创建所需的 SecureString 参数。Automation 使用 Parameter Store 中的预留命名空间,它是 Systems Manager 的一项功能,用于存储有关您的集成的信息。如果您使用 Amazon Web Services Management Console 创建集成,Automation 会为您处理此过程。在命名空间之后,您必须指定要创建的集成类型,然后指定集成的名称。目前,Automation 支持 webhook 类型集成。

webhook 类型集成支持的字段如下:

  • 描述

  • headers

  • payload

  • URL

开始前的准备工作

安装并配置 Amazon Command Line Interface (Amazon CLI) 或 Amazon Tools for PowerShell(如果尚未这样做)。有关信息,请参阅安装或更新 Amazon CLI 的最新版本以及安装 Amazon Tools for PowerShell

要为 Automation 创建集成(命令行)
  • 运行下列命令以为集成创建所需的 SecureString 参数。将每个示例资源占位符替换为您自己的信息。/d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/ 命名空间在 Parameter Store 中为集成预留。参数的名称必须使用此命名空间,后跟集成的名称。例如 /d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/myWebhookIntegration

    Linux & macOS
    aws ssm put-parameter \ --name "/d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/myWebhookIntegration" \ --type "SecureString" \ --data-type "aws:ssm:integration" \ --value '{"description": "My first webhook integration for Automation.", "url": "myWebHookURL"}'
    Windows
    aws ssm put-parameter ^ --name "/d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/myWebhookIntegration" ^ --type "SecureString" ^ --data-type "aws:ssm:integration" ^ --value "{\"description\":\"My first webhook integration for Automation.\",\"url\":\"myWebHookURL\"}"
    PowerShell
    Write-SSMParameter ` -Name "/d9d01087-4a3f-49e0-b0b4-d568d7826553/ssm/integrations/webhook/myWebhookIntegration" ` -Type "SecureString" -DataType "aws:ssm:integration" -Value '{"description": "My first webhook integration for Automation.", "url": "myWebHookURL"}'

为集成创建 Webhooks

在使用您的提供商创建 Webhooks 时,请注意以下几点:

  • 协议必须是 HTTPS。

  • 支持自定义请求标头。

  • 可以指定默认的请求正文。

  • 当使用 aws:invokeWebhook 操作调用集成时,可以覆盖默认的请求正文。