aws / aws/aws-sam-cli

start-api doesn't add the API stage to the routes

Open
#1,483 3 comments 0 reactions 0 assignees View on GitHub
area/local/start-api maintainer/need-followup type/bug
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description
When running `sam start-api` with a template that includes AWS::ApiGateway::Methods, AWS::ApiGateway::RestApi, AWS::ApiGateway::Resource, and AWS::ApiGateway::Stage resources (as announced in [0.21](https://github.com/awslabs/aws-sam-cli/releases/tag/v0.21.0)), it doesn't append the Stage name to the mounted endpoints

### Steps to reproduce

1. Define a Lambda serverless app with the resources above (I don't have an MRE at the minute)
1. Run `sam start-api`

### Observed result
`Mounting LambdaFunctionName at http://127.0.0.1:3000/apiPath [POST]`

(Debug output at the bottom)

### Expected result
`Mounting LambdaFunctionName at http://127.0.0.1:3000/stageName/apiPath [POST]`

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

* I debugged the code and it seems [this bit](https://github.com/awslabs/aws-sam-cli/blob/18908c16a685b14c72b8abebc91e5af3c6a75a75/samcli/local/apigw/local_apigw_service.py#L110) doesn't append the stage name to the Flask routes.
* I work at Amazon, I can share an MRE from our codebase if you reach out to me at seoaneg@

1. OS: Mac
2. `sam --version`: 0.23

`Add --debug flag to command you are running`
```
Using SAM Template at /Users/seoaneg/Workspaces/PCSecurityReviewService/src/PCSecurityReviewService/packages/infrastructure/template.yaml
Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
local start-api command is called
Collected default values for parameters: {}
Unable to resolve property AllocationId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcVPCPublicSubnet1EIPA390CEC2', 'AllocationId'])]). Leaving as is.
Unable to resolve property AllocationId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcVPCPublicSubnet2EIPD44B52EC', 'AllocationId'])]). Leaving as is.
Unable to resolve property AllocationId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcVPCPublicSubnet3EIP0C16B512', 'AllocationId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcGetSecurityReviewLambdaSecurityGroup61D8C697', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPutAnswerLambdaSecurityGroup80AACC7C', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostReviewStatusLambdaSecurityGroup54DC1DF3', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostQuestionsLambdaSecurityGroupD38FCC94', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostReviewVersionLambdaSecurityGroup9E615A73', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPutAnswerStatusLambdaSecurityGroup723D976C', 'GroupId'])]). Leaving as is.
Unable to resolve property VpcSecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcGetSecurityReviewLambdaSecurityGroup61D8C697', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPutAnswerLambdaSecurityGroup80AACC7C', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostReviewStatusLambdaSecurityGroup54DC1DF3', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostQuestionsLambdaSecurityGroupD38FCC94', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostReviewVersionLambdaSecurityGroup9E615A73', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPutAnswerStatusLambdaSecurityGroup723D976C', 'GroupId'])])]. Leaving as is.
177 resources found in the template
Found Lambda function with name='GammaPCSecurityReviewSvcGetSecurityReviewLambda2BCA0DDA' and CodeUri='/Users/seoaneg/Workspaces/PCSecurityReviewService/src/PCSecurityReviewService/packages'
Found Lambda function with name='GammaPCSecurityReviewSvcPutAnswerLambdaDF4DE497' and CodeUri='/Users/seoaneg/Workspaces/PCSecurityReviewService/src/PCSecurityReviewService/packages'
Found Lambda function with name='GammaPCSecurityReviewSvcPostReviewStatusLambda4789A865' and CodeUri='/Users/seoaneg/Workspaces/PCSecurityReviewService/src/PCSecurityReviewService/packages'
Found Lambda function with name='GammaPCSecurityReviewSvcPostQuestionsLambdaAD8C7517' and CodeUri='/Users/seoaneg/Workspaces/PCSecurityReviewService/src/PCSecurityReviewService/packages'
Found Lambda function with name='GammaPCSecurityReviewSvcPostReviewVersionLambda52F5BF2A' and CodeUri='/Users/seoaneg/Workspaces/PCSecurityReviewService/src/PCSecurityReviewService/packages'
Found Lambda function with name='GammaPCSecurityReviewSvcPutAnswerStatusLambdaCEDBFDA1' and CodeUri='/Users/seoaneg/Workspaces/PCSecurityReviewService/src/PCSecurityReviewService/packages'
Collected default values for parameters: {}
Unable to resolve property AllocationId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcVPCPublicSubnet1EIPA390CEC2', 'AllocationId'])]). Leaving as is.
Unable to resolve property AllocationId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcVPCPublicSubnet2EIPD44B52EC', 'AllocationId'])]). Leaving as is.
Unable to resolve property AllocationId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcVPCPublicSubnet3EIP0C16B512', 'AllocationId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcGetSecurityReviewLambdaSecurityGroup61D8C697', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPutAnswerLambdaSecurityGroup80AACC7C', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostReviewStatusLambdaSecurityGroup54DC1DF3', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostQuestionsLambdaSecurityGroupD38FCC94', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostReviewVersionLambdaSecurityGroup9E615A73', 'GroupId'])]). Leaving as is.
Unable to resolve property GroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])]). Leaving as is.
Unable to resolve property SourceSecurityGroupId: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPutAnswerStatusLambdaSecurityGroup723D976C', 'GroupId'])]). Leaving as is.
Unable to resolve property VpcSecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDbClusterSecurityGroup7FB132DD', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcGetSecurityReviewLambdaSecurityGroup61D8C697', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPutAnswerLambdaSecurityGroup80AACC7C', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostReviewStatusLambdaSecurityGroup54DC1DF3', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostQuestionsLambdaSecurityGroupD38FCC94', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPostReviewVersionLambdaSecurityGroup9E615A73', 'GroupId'])])]. Leaving as is.
Unable to resolve property dbEndpoint: OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcDocumentDbCluster', 'Endpoint'])]). Leaving as is.
Unable to resolve property SecurityGroupIds: [OrderedDict([('Fn::GetAtt', ['GammaPCSecurityReviewSvcPutAnswerStatusLambdaSecurityGroup723D976C', 'GroupId'])])]. Leaving as is.
177 resources found in the template
Skipping resource 'GammaPCSecurityReviewSvcApi35B2AC66'. Swagger document not found in Body and BodyS3Location
Extracted Function ARN: arn:aws:lambda:us-east-1:123456789012:function:GammaPCSecurityReviewSvcGetSecurityReviewLambda2BCA0DDA
Extracted Function ARN: arn:aws:lambda:us-east-1:123456789012:function:GammaPCSecurityReviewSvcPutAnswerLambdaDF4DE497
Extracted Function ARN: arn:aws:lambda:us-east-1:123456789012:function:GammaPCSecurityReviewSvcPutAnswerStatusLambdaCEDBFDA1
Extracted Function ARN: arn:aws:lambda:us-east-1:123456789012:function:GammaPCSecurityReviewSvcPostReviewStatusLambda4789A865
Extracted Function ARN: arn:aws:lambda:us-east-1:123456789012:function:GammaPCSecurityReviewSvcPostQuestionsLambdaAD8C7517
Extracted Function ARN: arn:aws:lambda:us-east-1:123456789012:function:GammaPCSecurityReviewSvcPostReviewVersionLambda52F5BF2A
6 APIs found in the template
Mounting GammaPCSecurityReviewSvcGetSecurityReviewLambda2BCA0DDA at http://127.0.0.1:3000/v1/projects/{project_id}/security_review [GET]
Mounting GammaPCSecurityReviewSvcPutAnswerLambdaDF4DE497 at http://127.0.0.1:3000/v1/projects/{project_id}/security_review/{question_id}/answer [PUT]
Mounting GammaPCSecurityReviewSvcPutAnswerStatusLambdaCEDBFDA1 at http://127.0.0.1:3000/v1/projects/{project_id}/security_review/{question_id}/answer/status [PUT]
Mounting GammaPCSecurityReviewSvcPostReviewStatusLambda4789A865 at http://127.0.0.1:3000/v1/projects/{project_id}/security_review/status [POST]
Mounting GammaPCSecurityReviewSvcPostQuestionsLambdaAD8C7517 at http://127.0.0.1:3000/v1/security_review/questions [POST]
Mounting GammaPCSecurityReviewSvcPostReviewVersionLambda52F5BF2A at http://127.0.0.1:3000/v1/security_review/{type}/version [POST]
You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
Localhost server is starting up. Multi-threading = True
2019-10-25 18:26:19 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
```

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.