aws-lambda-proxy-using-sam-local icon indicating copy to clipboard operation
aws-lambda-proxy-using-sam-local copied to clipboard

template.yaml doesn't pass the sam validate

Open cloud226 opened this issue 7 years ago • 2 comments

invalid YAML template: json: unsupported type: map[interface {}]interface {}

cloud226 avatar Apr 26 '18 06:04 cloud226

Encountered the same problem. To resolve I updated line 54:

-        !Sub
+        Fn::Sub:

That ^^^ should be enough to pass sam validate.

Next I tried running sam local start-api but was stopped by:

Cannot parse Swagger definition: json: cannot unmarshal number into Go struct field SwaggerProps.swagger of type string

To resolve this one I updated the swagger version field on line 92 from a number to a string:

-        swagger: 2.0
+        swagger: "2.0"

I can now start the test environment, but I'm unable to successfully hit the endpoint. When I try to load/curl http://localhost:3000 I get:

{ "message": "No function defined for resource method" }

btalberg avatar May 01 '18 14:05 btalberg

The "No function defined..." issue was also reported here: https://github.com/awslabs/aws-sam-local/issues/289

Replacing the ANY http method with GET and POST handlers solves all example cases from the README:

    Events:
        GetRequest:
          Type: Api
          Properties:
            Path: /
            Method: GET
            RestApiId: !Ref ExampleAPI
        PostRequest:
          Type: Api
          Properties:
            Path: /
            Method: POST
            RestApiId: !Ref ExampleAPI

btalberg avatar May 01 '18 15:05 btalberg