0

In my SAM templates, my team has defined an API that is mostly to our liking. I would like to debug this API locally, but it isn't set explicitly as an Event under our Function. So sam local start-api fails with the error

Error: Template does not have any APIs connected to Lambda functions

How can I convince SAM that the API we have defined is the event meant to invoke this Lambda? What should I do to test this locally?

edit - to clarify, the current template structure looks something like

  Lambda:
    Type: AWS::Serverless::Function
    Properties:
...
  LambdaRole:
....
  MAILAPI:
    Type: AWS::Serverless::Api
    Properties:
    ...
Vincent Buscarello
  • 395
  • 2
  • 7
  • 19

1 Answers1

0

Not sure if this implements all the gateway params we defined so I wont mark this as resolved yet, but this is a promising start!

This allowed me to start the API as expected locally

 Events:
    Api:
      Type: Api
      Properties:
        Path: /
        Method: post
        RestApiId: 
          Ref: MAILAPI

With (of course) our API resource defined under the MAILAPI label (edited question to show this)

Vincent Buscarello
  • 395
  • 2
  • 7
  • 19