Aws-sam-cli: YAML is not recognized when using !Sub

Created on 13 Aug 2017  Â·  6Comments  Â·  Source: aws/aws-sam-cli

When trying to use sam-local with the project https://github.com/taimos/serverless-todo-demo it fails with the following error:

ERROR:  did not find expected alphabetic or numeric character (line: 34; col: 0)

Line 34 uses the string substitution for the IAM permission to DynamoDB:

- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TodoTable}
goformation typbug

Most helpful comment

I am still getting this error :/

All 6 comments

Yet another goformation bug. I'll take a look shortly

Fixed on goformation. Need to update this release.

Need a test case to validate fix before release. Is there one?

I tried with the project I mentioned above and ran sam local start-api or sam validate and both failed with the given error.

I got pass the initial failure of not being able to parse !Sub by converting a line like:

Prop: !Sub "my-sub-${RefValue}" throws an error: ☯ sam validate -t sam.yaml 2017/08/14 11:12:19 0.1.0 ERROR: Invalid indentation in template (line: 586; col: 0)

to

Prop: !Sub
  - "my-sub-${RefValue}"
  - {}

and got this error:

2017/08/14 11:12:54 0.1.0
panic: interface conversion: interface {} is map[interface {}]interface {}, not string

goroutine 1 [running]:
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.safeProcessStringArray(0x196b820, 0xc42079ad20, 0x167733c, 0x8, 0xc4201d1bd8)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/safe-processing.go:46 +0x15f
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.(*functionTemplate).Scaffold(0xc420286420, 0x196b860, 0xc420139200, 0x0, 0x0, 0xe, 0x168b7c4, 0x26, 0x0)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/aws-serverless-function.go:146 +0x3bf
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.(*awsServerlessFunction).Scaffold(0x19bcdc0, 0x196b860, 0xc420139200, 0x0, 0x0, 0x26, 0x0, 0x0, 0x0)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/aws-serverless-function.go:80 +0x6a
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.(*awsServerlessFunction).ClassConstructor(0x19bcdc0, 0x196b860, 0xc420139200, 0x0, 0x0, 0x0, 0x0)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/aws-serverless-function.go:61 +0x55
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.postProcess(0x196e4e0, 0xc420132190, 0x196e4e0, 0xc420132190, 0x0, 0x0)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/post-process.go:46 +0x533
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.Parse(0xc420350000, 0x4efb, 0x7e00, 0x4efb, 0x7e00, 0x0, 0x0, 0xc4204a2028, 0x0)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:72 +0x407
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.read(0x1966360, 0xc4204a2028, 0xc4204a2028, 0x0, 0x0, 0x0, 0x1, 0x1)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:40 +0x105
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.Open(0x7fff5fbfec40, 0x8, 0x7fff5fbfec40, 0x8, 0x8, 0x0, 0x0, 0xc420316f90)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:29 +0x27e
main.validate(0xc4203ccf00)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/validate.go:13 +0x7a
github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli.HandleAction(0x1587e60, 0x169a720, 0xc4203ccf00, 0xc4204a8800, 0x0)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli/app.go:487 +0x7c
github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli.Command.Run(0x1677894, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16971ee, 0xa7, 0x0, ...)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli/command.go:207 +0xb72
github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli.(*App).Run(0xc42058e680, 0xc42007a080, 0x4, 0x4, 0x0, 0x0)
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli/app.go:250 +0x7d0
main.main()
    /home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/main.go:302 +0x1be1

I am still getting this error :/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asyba picture asyba  Â·  3Comments

debuggins picture debuggins  Â·  4Comments

Caian picture Caian  Â·  3Comments

cvuijst picture cvuijst  Â·  3Comments

jpbarto picture jpbarto  Â·  4Comments