AWS SAM - Template does not have any APIs connected to Lambda functions

This error message also displays if you are trying to test a websocket API locally. Unfortunately, local testing of websockets is not currently supported - see

You didn't add any API Gateway event to your function. And start-api spawn a local API Gateway.

You need to add at least one Api event to your Events section.

    Type: Api
      Path: /myresource
      Method: get

If you just have a Schedule event, try to use generate-event to create such an event.

sam local generate-event schedule ...

and invoke function e.g. sam local invoke function-name -e event_file.json (see)

For Googlers:

  • Check whether you have an Event with Type: Api
  • ALSO check whether you have run sam build (very important)
  • Use the --debug flag so you will know what is going on

As of 2020/7/13, Type: HttpApi does not work with sam local start-api. See issue.

I ran into this error too even when I did have an Api event defined in my SAM template. The problem was that I had a previous template in my .aws-sam/build/ directory which didn't have the Api event defined (from a previous run of sam build). Cleaning out the build directory fixed it.