我有AWS步骤机,步骤之一用于使用SNS服务通知失败。我想从input
json中选择一些元数据到传出消息中。所以我试图用下面的jsonpath连接常量字符串
"Notify Failure": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters": {
"Message.$": "A job submitted through Step Functions failed for document id $.document_id",
"Subject":"Job failed",
"TopicArn": "arn:aws:sns:us-west-2:xxxxxxx:xxxxxxxx"
},
"End": true
}
其中document_id
是输入json中的属性之一
但是,当我尝试保存状态机定义时,会出现错误
您的ASL定义存在问题,请对其进行检查并尝试 再次,“ Message。$”字段的值必须是有效的JSONPath
答案 0 :(得分:9)
我能够使用以下方法解决类似的问题:
"Message.$": "States.Format('A job submitted through Step Functions failed for document id {}', $.document_id)",
在AWS News Blog post中进行了描述。
答案 1 :(得分:3)
通过$.concat($..prop)
从AWS Step Functions文档supports String concatenation引用的JSONPath实现,但遗憾的是,当部署到AWS时,此方法不起作用,表明AWS使用了不同的实现。
因此,无法在AWS中使用JSONPath进行字符串连接。
答案 2 :(得分:0)
根据消息提示,您需要提供有效的JSONPath。
"Message.$": "$.document_id"
您不能使用任何字符串插值,因为它会使JSONPath格式无效。您将需要以先前的状态构造消息。