【问题标题】:Where/how do I define a NotificationConfig in an AWS SSM Automation document?我在哪里/如何在 AWS SSM 自动化文档中定义 NotificationConfig?
【发布时间】:2021-04-11 14:17:16
【问题描述】:

假设我有一个如下所示的 SSM 文档,并且我希望在运行失败或由于任何原因未完成时收到警报:

{
  "description": "Restores specified pg_dump backup to specified RDS/DB.",
  "mainSteps": [
    {
      "action": "aws:runCommand",
      "description": "Restores specified pg_dump backup to specified RDS/DB.",
      "inputs": {
        "DocumentName": "AWS-RunShellScript",
        "Parameters": {
          "commands": [
            "blahblahblah"
          ],
          "executionTimeout": "1800"
        },
        "Targets": [
          {
            "Key": "InstanceIds",
            "Values": [
              "i-xxxxxxxx"
            ]
          }
        ]
      },
      "name": "DBRestorer",
      "nextStep": "RunQueries"
    },

Terraform 文档告诉我,RunCommand 文档应该支持 NotificationConfig,我可以在其中传入我的 SNS 主题 ARN 并声明哪些状态转换应该触发消息:https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_maintenance_window_task#notification_config

但是,我找不到任何实际包含在文档本身中使用通知配置的 Amazon 文档(不仅仅是维护窗口,我已将其设置为自动化,因此它在窗口中不支持它level),所以我不确定它是否属于子参数,或者是否用驼峰式或破折号分隔来定义它。

【问题讨论】:

    标签: amazon-web-services aws-ssm amazon-systems-manager


    【解决方案1】:

    试试这个

    {
      "description": "Restores specified pg_dump backup to specified RDS/DB.",
      "mainSteps": [
        {
          "action": "aws:runCommand",
          "description": "Restores specified pg_dump backup to specified RDS/DB.",
          "inputs": {
            "DocumentName": "AWS-RunShellScript",
            "NotificationConfig": {
              "NotificationArn": "<<Replace this with a SNS Topic Arn>>",
              "NotificationEvents": ["All"],
              "NotificationType": "Invocation"
            },
            "ServiceRoleArn": "<<Replace this with an IAM role Arn that has access to SNS>>",
            "Parameters": {
              "commands": [
                "blahblahblah"
              ],
              "executionTimeout": "1800"
            },
            "Targets": [
              {
                "Key": "InstanceIds",
                "Values": [
                  "i-xxxxxxxx"
                ]
              }
            ]
          },
          "name": "DBRestorer",
          "nextStep": "RunQueries"
        },
        ...
      ]
    }
    

    相关文档:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 2018-05-21
      • 1970-01-01
      • 2011-05-02
      相关资源
      最近更新 更多