微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我在哪里/如何在 AWS SSM 自动化文档中定义 NotificationConfig?

如何解决我在哪里/如何在 AWS SSM 自动化文档中定义 NotificationConfig?

假设我有一个如下所示的 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

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

解决方法

试试这个

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

相关文档:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。