简体   繁体   English

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

[英]Where/how do I define a NotificationConfig in an AWS SSM Automation document?

Say I have an SSM document like the below, and I want to be alerted when a run fails or doesn't finish for whatever reason:假设我有一个如下所示的 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 documents show me that RunCommand documents should support a NotificationConfig where I can pass in my SNS topic ARN and declare what state transitions should trigger a message: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_maintenance_window_task#notification_config Terraform documents show me that RunCommand documents should support a NotificationConfig where I can pass in my SNS topic ARN and declare what state transitions should trigger a message: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/资源/ssm_maintenance_window_task#notification_config

However, I can't find any Amazon docs that actually include the use of a notification configuration in the document itself (not just the maintenance window, which I have set up as automation so it doesn't support it at the window level), so I'm not sure if it belongs as a sub-parameter, or whether to define it with camel case or dash separation.但是,我找不到任何实际包含在文档本身中使用通知配置的 Amazon 文档(不仅仅是维护 window,我已将其设置为自动化,因此它在 window 级别不支持它),所以我不确定它是否属于子参数,或者是否用驼峰式或破折号分隔来定义它。

Try this尝试这个

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

Related documentation:相关文档:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS SSM 文档自动化循环 - AWS SSM Document Automation loop 如何每天执行 AWS SSM 自动化文档脚本? - How to execute AWS SSM automation document script daily? 如何从AWS SSM文档中正确引用Powershell脚本? - How do I properly reference a Powershell script from an AWS SSM document? AWS Cloudformation SSM 自动化文档 | 与 aws cloudformation package 一起使用 - AWS Cloudformation SSM automation document | use with aws cloudformation package AWS-RunShellScript 中的 ssm 自动化文档输入不替换变量 - ssm automation document input in AWS-RunShellScript not substituting variable AWS SSM 自动化:如何在 aws:executeScript 调用的脚本中正常失败 - AWS SSM Automation: How to gracefully fail in script invoked by aws:executeScript 如何使用 Terraform 的 aws_ssm_document 在目标 VM 上运行 powershell 脚本 - How can I run a powershell script on a target VM using Terraform's aws_ssm_document 如何使用 CloudFormation 创建具有 DocumentType 包的“AWS::SSM::Document” - How to create an 'AWS::SSM::Document' with DocumentType of Package using CloudFormation 使用参数从 AWS SSM 自动化执行 Lambda - Execute Lambda from AWS SSM Automation with Parameters 带有私人信息的AWS SSM文档 - AWS SSM document with private information
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM