0

我有一个非常长但重复的 json 格式的状态机定义,我正在尝试使用状态机块的DefinitionSubstitutions属性将一些常见块提取到 AWS SAM 模板中。例如,我有这样的Retry政策:

{
    "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

我不明白我做错了什么。

4

0 回答 0