【发布时间】:2021-07-22 20:58:37
【问题描述】:
我正在构建一个 AWS CloudFormation 文件,但我被困在 AWS::Events::Rule 服务中。我正在尝试制定一个规则,为 CodePipeline 的每个阶段向开发人员发送一封电子邮件。这是整个文件:
{
"PipelineWebpageAccessStageNotification": {
"Type": "AWS::Events::Rule",
"Properties": {
"Description": "Send out notifications to developers about the CodePipeline stages status for the websites.",
"Name": "codepipeline-webpage_access",
"RoleArn": { "Fn::GetAtt": ["PipelineWebpageAccessStageNotificationRole", "Arn" ] },
"EventPattern": {
"source": [
"aws.codepipeline"
],
"detail-type": [
"CodePipeline Stage Execution State Change"
],
"detail": {
"pipeline": [
{ "Ref": "PipelineWebpageAccess" }
],
"state": [
"FAILED",
"CANCELED",
"RESUMED",
"SUCCEEDED",
"STARTED"
]
}
},
"State": "ENABLED",
"Targets": [
{
"Arn": { "Ref": "SNSTopic" },
"Id": "SNS",
"InputTransformer": {
"InputPathsMap": {
"pipeline": "$.detail.pipeline",
"stage": "$.detail.stage",
"state": "$.detail.state"
},
"InputTemplate": "Hello Human, This message is related to the CodePipeline: <pipeline>. Bellow are some details: \r\n\r\n - Stage: <stage>\r\n - Status: <state>\r\n\r\n Thank you for reading, Enjoy your existence."
}
}
]
}
}
}
问题在于InputTemplate。 CloudFormation 告诉我发送一个字符串。我在做什么......原来你实际上必须发送一个包含 JSON 的字符串。好的,所以我这样做了,就像在其他地方一样,例如,当您在 CloudWatch 中构建仪表板时,您使用 JSON 传递一个字符串。这没有问题。但在这里 - 它一直在失败。
有趣的是,同样的问题也发生在 AWS Dashboard 中。
我确实与 AWS Tach Support 进行了交谈,他们也不知道如何解决这个问题,他们确实提供了一些尝试的方法,但都没有奏效。
他们告诉我,他们将询问负责 AWS 这部分的团队,但我并不抱太大希望。
问题
如果您遇到同样的问题,并且知道如何解决,我们将不胜感激:)
【问题讨论】:
-
文档对此很奇怪,阅读
InputTemplate下方的链接应该是这样的:"InputTemplate": "\"Hello Human, This message is related to the CodePipeline: <pipeline>. Bellow are some details: \r\n\r\n - Stage: <stage>\r\n - Status: <state>\r\n\r\n Thank you for reading, Enjoy your existence.\""。 forums.aws.amazon.com/thread.jspa?messageID=798687
标签: amazon-web-services amazon-cloudformation amazon-cloudwatch amazon-ses