【问题标题】:CloudFormation YAML State Machine: INVALID_JSON_DESCRIPTION for unrecognized tokenCloudFormation YAML 状态机:无法识别令牌的 INVALID_JSON_DESCRIPTION
【发布时间】:2020-09-14 00:21:58
【问题描述】:

我有以下代码来使用 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 在定义字符串中都被正确引用,所以这可能不是问题。

【问题讨论】:

    标签: yaml amazon-cloudformation aws-step-functions serverless-application-model


    【解决方案1】:

    这应该是一个json,所以lambdaArnlambda2ArnsnsArn应该在引号中:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-29
      • 2016-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多