aws / aws/aws-sam-cli

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

Open
#2,754 4 comments 0 reactions 0 assignees View on GitHub
maintainer/need-followup stage/pm-review type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:
I am using SAM to create a step function with a local API gateway to test some functionality. I can build the template fine, but when I run using `sam local start-api -t my_template.yaml --debug`, I get this error

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

### Steps to reproduce:

Template file
```yaml
AWSTemplateFormatVersion: "2010-09-09"
Transform: "AWS::Serverless-2016-10-31"
Description: Event driven architecture for creating and uploading PDFs to Box.
Resources:
UploaderStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Name: uploader-state-machine
DefinitionUri: my_definition.json
Events:
MyApi:
Type: Api
Path: /
Method: POST
```

### Observed result:

```
2021-03-22 13:41:47,899 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2021-03-22 13:41:47,899 | Using config file: samconfig.toml, config environment: default
2021-03-22 13:41:47,899 | Expand command line arguments to:
2021-03-22 13:41:47,899 | --template_file=/Users/johndoe/projects/test-service/serverless/my_template.yaml --host=127.0.0.1 --port=3000 --static_dir=public --layer_cache_basedir=/Users/johndoe/.aws-sam/layers-pkg
2021-03-22 13:41:48,007 | local start-api command is called
2021-03-22 13:41:48,011 | No Parameters detected in the template
2021-03-22 13:41:48,039 | 1 stacks found in the template
2021-03-22 13:41:48,039 | No Parameters detected in the template
2021-03-22 13:41:48,060 | 1 resources found in the stack
2021-03-22 13:41:48,060 | No Parameters detected in the template
2021-03-22 13:41:48,090 | No Parameters detected in the template
2021-03-22 13:41:48,109 | No Parameters detected in the template
2021-03-22 13:41:48,130 | Removed duplicates from '0' Explicit APIs and '0' Implicit APIs to produce '0' APIs
2021-03-22 13:41:48,130 | 0 APIs found in the template
2021-03-22 13:41:48,135 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '01f63b20-53d6-42d2-902f-d85dbe016f7c', 'installationId': '822dc94d-3c39-4026-969d-ae9c01b7f5ba', 'sessionId': 'f69e676b-5c19-4c91-b252-363743a4febd', 'executionEnvironment': 'CLI', 'pyversion': '3.8.8', 'samcliVersion': '1.21.1', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local start-api', 'duration': 235, 'exitReason': 'NoApisDefined', 'exitCode': 1}}]}
2021-03-22 13:41:48,451 | Telemetry response: 200
Error: Template does not have any APIs connected to Lambda functions
```

### Expected result:

I thought an API gateway would be created locally for me to use if I didn't explicitly create one.

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS: Mac OSX Catalina (10.15.7)
2. `sam --version`: 1.21.1
3. AWS region: just testing locally

`Add --debug flag to command you are running`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.