0

假设我有一个如下所示的 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/资源/ssm_maintenance_window_task#notification_config

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

4

1 回答 1

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"
    },
    ...
  ]
}

相关文档:

于 2021-04-09T04:42:10.890 回答