Tib*_*rzz 1 amazon-web-services aws-cloudformation amazon-cloudwatch
我正在尝试使用cloudformation模板创建一个与胶粘事件匹配的Cloudwatch事件规则,并以SNS主题为目标向其发送消息,我可以在cloudwatch控制台中创建它,但是不能通过cloud watch模板创建它。这是我的活动规则:
NotifyEventRule:
Type: AWS::Events::Rule
Properties:
Name: JobNotifyEvent
Description: Notification event on job status change.
EventPattern:
source:
- aws.glue
account:
- !Ref AWS::AccountId
detail-type:
- Glue Job State Change
detail:
jobName:
- !Ref GlueJobName
Targets:
-
Arn:
Ref: "JobNotificationTopic"
Id:
Ref: "JobNotificationTopicName"
InputTransformer:
InputTemplate: "Job finished in the following state: <state>."
InputPathsMap:
state: "$.detail.state"
Run Code Online (Sandbox Code Playgroud)
问题出在InputTemplate上。我得到的错误是:
“,目标JobNotificationTopic的InputTemplate无效:[源:(String)”作业在以下状态下完成:null。“; 行:1,列:10]。(服务:AmazonCloudWatchEvents;状态代码:400;错误代码:ValidationException;请求ID:12345678 ...)
看来<state>可能是问题所在。
由于某种原因,在CloudFormation中,InputTemplate的语法非常严格。它是字符串类型,但不接受任何形式的有效YAML字符串。
在您的情况下,应在输入字符串之前使用YAML文字块标量|。
InputTransformer:
InputPathsMap:
state: "$.detail.state"
InputTemplate: |
"Job finished in the following state: <state>."
Run Code Online (Sandbox Code Playgroud)
如果输入字符串是多行,则每行必须用双引号引起来。
InputTransformer:
InputPathsMap:
state: $.detail.state
name: $.detail.name
InputTemplate: |
"Job <name> has just been run."
"Job finished in the following state: <state>."
Run Code Online (Sandbox Code Playgroud)
只是要注意,您的字符串使用普通流标量,这对:字符很挑剔。冒号不能出现在空格或换行符之前。有关更多详细信息,请参见 Yaml multiline。但是,正如我指出的那样,这些大多数YAML多行规则不适用于InputTemplate。
小智 5
这不是 YAML 格式的问题,因为您使用 JSON 会遇到相同的错误。
InputTemplate 必须是 AWS 中的字符串:
InputTemplate=
"\"The Pipeline <pipeline> Started\""
Run Code Online (Sandbox Code Playgroud)
这个 AWS 开发人员论坛主题给了我答案:https : //forums.aws.amazon.com/thread.jspa?messageID=798687
| 归档时间: |
|
| 查看次数: |
1558 次 |
| 最近记录: |