Amazon web services 如何在AWS SAM状态机定义中使用多行参数?

Amazon web services 如何在AWS SAM状态机定义中使用多行参数?,amazon-web-services,aws-sam,aws-sam-cli,aws-state-machine,Amazon Web Services,Aws Sam,Aws Sam Cli,Aws State Machine,我有一个非常长但重复的json格式的状态机定义,我试图使用状态机块的属性将一些公共块提取到AWS SAM模板中。例如,我有一个重试策略,如下所示: { "StartAt": "Generate Config", "States": { "Generate Config": { "Type": "Task",

我有一个非常长但重复的json格式的状态机定义,我试图使用状态机块的属性将一些公共块提取到AWS SAM模板中。例如,我有一个
重试
策略,如下所示:

{
    "StartAt": "Generate Config",
    "States": {
        "Generate Config": {
            "Type": "Task",
            "Resource": "${GenerateConfigFunctionArn}",
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.TaskFailed"
                    ],
                    "IntervalSeconds": 15,
                    "MaxAttempts": 5,
                    "BackoffRate": 1.5
                }
            ],
            "Next": "Process basins"
        },
...
我想将重试块提取到AWS SAM模板中,如下所示:

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Resources:
  PredictiveAnalyticsPipelineOrchestration:
    Type: AWS::Serverless::StateMachine
    Properties:
      DefinitionUri: stateMachine/definition.asl.json
      DefinitionSubstitutions:
        GenerateConfigFunctionArn: !GetAtt GenerateConfigFunction.Arn
        RetryPolicy: |
          [
            {
                "ErrorEquals": [
                    "States.ALL"
                ],
                "IntervalSeconds": 10,
                "MaxAttempts": 2,
                "BackoffRate": 1.5
            }
          ]
...
因此,上述内容变成:

{
    "StartAt": "Generate Config",
    "States": {
        "Generate Config": {
            "Type": "Task",
            "Resource": "${GenerateConfigFunctionArn}",
            "Retry": "${RetryPolicy}",
            "Next": "Process basins"
        },
...
但是,当我运行aws deploy时,我得到一个错误:

Resource handler returned message: "Invalid State Machine Definition:
'INVALID_JSON_DESCRIPTION: Illegal unquoted character ((CTRL-CHAR, code 10)):
 has to be escaped using backslash to be included in string value

我不明白我做错了什么。

应该
“重试”:“${RetryPolicy}”,
应该
“重试”:“${RetryPolicy}”,
?谢谢你的评论@petey。但是,我认为这不是使用令牌的正确语法。实际上,
“Retry”上面有一个工作示例“${RetryPolicy}”
行。例如,
“Resource”:“${GenerateConfigFunctionArn}”,
正在使用带有双引号的令牌。当我使用“Retry”时:
${RetryPolicy}
,我得到一个错误:
无效的状态机定义