CloudFormation YAML 状态机:INVALID_JSON_DESCRIPTION 无法识别的令牌

CloudFormation YAML State Machine: INVALID_JSON_DESCRIPTION for unrecognized token

我有以下代码使用 CloudFormation 部署 Step Functions 状态机:

...
DefinitionString: 
        !Sub
          - |
            {
              "StartAt": "Save Artifact to S3",
              "States": {
                "Save Artifact to S3": {
                  "Type": "Task",
                  "Resource": ${lambdaArn},
                  "Next": "Format Notification"
                },
                "Format Notification": {
                  "Type": "Task",
                  "Resource": ${lambda2Arn},
                  "Next": "Publish to SNS"
                },
                "Publish to SNS": {
                  "Type": "Task",
                  "Resource": "arn:aws:states:::sns:publish",
                  "Parameters": {
                    "TopicArn": ${snsArn},
                    "Message.$": "$.message",
                    "Subject.$": "$.subject"
                  },
                  "End": true
                }
              }
            }
          - lambdaArn: !GetAtt SavetoS3Function.Arn
            lambda2Arn: !GetAtt NotifyUserFunction.Arn
            snsArn: !Ref NotifyUserTopic
...

使用SAM在AWS上部署,出现如下错误:

Invalid State Machine Definition: 'INVALID_JSON_DESCRIPTION: Unrecognized token 'arn': was expecting ('true', 'false' or 'null')  at [Source: (String)...

其他一切看起来都是正确的,那么这里发生了什么?所有 Arns 都在定义字符串中被正确引用,所以这可能不是问题所在。

这应该是 json,所以 lambdaArnlambda2ArnsnsArn 应该在 quotations:

        {
          "StartAt": "Save Artifact to S3",
          "States": {
            "Save Artifact to S3": {
              "Type": "Task",
              "Resource": "${lambdaArn}",
              "Next": "Format Notification"
            },
            "Format Notification": {
              "Type": "Task",
              "Resource": "${lambda2Arn}",
              "Next": "Publish to SNS"
            },
            "Publish to SNS": {
              "Type": "Task",
              "Resource": "arn:aws:states:::sns:publish",
              "Parameters": {
                "TopicArn": "${snsArn}",
                "Message.$": "$.message",
                "Subject.$": "$.subject"
              },
              "End": true
            }
          }