aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.5k stars 1.17k forks source link

None of the Serverless functions in your SAM template have valid API event sources. #96

Closed rogervanwile closed 7 years ago

rogervanwile commented 7 years ago

I try to run a lambda function for a alexa skill locally.

I'm using this template, found here https://github.com/awslabs/aws-sam-local/blob/develop/test/templates/sam-official-samples/alexa_skill/template.yaml

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Alexa Skill https://developer.amazon.com/alexa-skills-kit
Resources:
  AlexaSkillFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://<bucket>/alexa_skill.zip
      Handler: index.handler
      Runtime: nodejs4.3
      Events:
        AlexaSkillEvent:
          Type: AlexaSkill
          Properties:
            Whatever: whatever

But the startup fails with following output:

$ sam local start-api
2017/08/27 12:15:30 Connected to Docker 1.30
2017/08/27 12:15:30 Successfully parsed template.yaml
ERROR: None of the Serverless functions in your SAM template have valid API event sources.

What does it mean?

My index.js is running fine in lambda:

const Alexa = require('alexa-sdk');

const APP_ID = 'XXX';

const handlers = {
    ...
};

exports.handler = function (event, context) {
    const alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    alexa.registerHandlers(handlers);
    alexa.execute();
};
PaulMaddox commented 7 years ago

Hi @rogervanwile,

sam local start-api starts a local API Gateway, for testing functions that have API event sources.

Your example above doesn't have any events with Type: Api, so you should use sam local invoke instead, which just invokes a single function from the command line.