Aws-sam-cli: Parsing template fails due to unsupported type: map[interface {}]interface {}

Created on 30 Mar 2018  路  4Comments  路  Source: aws/aws-sam-cli

Sam local is unable to parse following template.

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'

Resources:
  StateMachine:
    Type: "AWS::StepFunctions::StateMachine"
    Properties:
      StateMachineName: "SamStateMachine"
      RoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/StateMachineServiceRole"
      DefinitionString:
        !Sub
          - |-
             {
               "Comment": "${application}",
               "StartAt": "HelloWorld",
               "States": {
                 "HelloWorld": {
                   "Type": "Pass",
                   "Result": {
                       "x-datum": 0.381018,
                       "y-datum": 622.2269926397355
                     },
                   "ResultPath": "$.coords",
                   "End": true
                 }
               }
             }
          - {
            application: "applicationName"
          }

When I execute sam validate the following error is thrown
invalid YAML template: json: unsupported type: map[interface {}]interface {}.
I'm running sam local 0.2.7 on Windows 10.

arevalidate

Most helpful comment

@sbuzonas You can use a sequence. The first is your string containing parameters and the second specifying the values of these parameters. See Intrinsic Function Reference 禄 Fn::Sub

@bgrindy Replacing !Sub with Fn::Sub: is indeed a workaround.

I don't want to close this issue as SAM Local should support !Sub too.

All 4 comments

I'm dealing with this issue too, same as #135

It looks like you have your !Sub in the wrong place. It should be in front of a string, not a sequence.

@sbuzonas You can use a sequence. The first is your string containing parameters and the second specifying the values of these parameters. See Intrinsic Function Reference 禄 Fn::Sub

@bgrindy Replacing !Sub with Fn::Sub: is indeed a workaround.

I don't want to close this issue as SAM Local should support !Sub too.

The validate command was integrated with SAM so this should not be an issue any longer.

Closing as this is fixed in 0.3.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jpbarto picture jpbarto  路  4Comments

Caian picture Caian  路  3Comments

terlar picture terlar  路  3Comments

asyba picture asyba  路  3Comments

zhangzhx picture zhangzhx  路  3Comments