gpt4 book ai didi

amazon-web-services - Cloudformation Cloudwatch 输入模板格式

转载 作者:行者123 更新时间:2023-12-01 04:29:39 48 4
gpt4 key购买 nike

我正在尝试使用cloudformation模板创建一个cloudwatch事件规则,该规则与glue事件匹配并定位要发送消息的SNS主题,我可以在cloudwatch控制台中创建它,但不能通过云监视模板创建。这是我的事件规则:

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"

问题出在 InputTemplate 上。我得到的错误是:

Invalid InputTemplate for target JobNotificationTopic : [Source: (String)"Job finished in the following state: null."; line: 1, column: 10]. (Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException; Request ID: 12345678...)

看起来 <state> 可能是问题所在。

最佳答案

出于某种原因,CloudFormation 中的 InputTemplate 语法相当严格。它是字符串类型,但不接受任何形式的有效 YAML 字符串。

在您的情况下,您应该在输入字符串之前使用 YAML Literal Block Scalar | |。

InputTransformer:
InputPathsMap:
state: "$.detail.state"
InputTemplate: |
"Job finished in the following state: <state>."

如果输入字符串是多行,则每行都必须用双引号引起来。

InputTransformer:
InputPathsMap:
state: $.detail.state
name: $.detail.name
InputTemplate: |
"Job <name> has just been run."
"Job finished in the following state: <state>."

请注意,您的字符串使用普通流标量,这对 : 字符很挑剔。冒号不能出现在空格或换行符之前。请参阅Yaml multiline了解更多详情。但是,正如我所指出的,大多数 YAML 多行规则并不适用于 InputTemplate。

关于amazon-web-services - Cloudformation Cloudwatch 输入模板格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52050539/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com