问题描述
假设我有一个如下所示的 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"
},...
]
}
相关文档: