aws / aws/aws-sam-cli

AWS::ApiGatewayV2::ApiMapping ApiMappingKey not honored in local development

Open
#3,635 1 comment 2 reactions 0 assignees View on GitHub
area/local/start-api type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:
When using a AWS::ApiGatewayV2::ApiMapping configuration with an ApiMappingKey, the key is not honored when running local development flow using "sam local start-api", and the raw API Path part of the HttpApi event in the function is used without ApiMappingKey pre-fix.

### Steps to reproduce:
```
Resources:
UserAPI:
Type: AWS::Serverless::HttpApi
Properties:
StageName: Staging
CorsConfiguration: True
UserAPIMapping:
Type: AWS::ApiGatewayV2::ApiMapping
Properties:
ApiId: !Ref UserAPI
DomainName: "my.domain.com"
ApiMappingKey: "user"
Stage: !Ref UserAPI.Stage
GetUserFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: getUser.lambda_handler
Architectures:
- x86_64
Events:
GetUserApiEvent:
Type: HttpApi
Properties:
Path: /{user_id}
Method: GET
ApiId: !Ref UserAPI
```

### Observed result:
When working locally, the resulting URI is:

http://127.0.0.1:5000/THISISMYUSERID

When working in Lambda against a deployed resource, the resulting URI is:

https://my.domain.com/user/THISISMYUSERID

### Expected result:
I would expect my local URI to match the Lambda URI taking into account the ApiMappingKey:

http://127.0.0.1:5000/user/THISISMYUSERID

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.