Path variables are not compatible with API Gateway
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description
It is possible to extract variables from path when using `sam local start-api` but not all supported cases are valid for deployment to AWS API Gateway.
### Steps to reproduce
Create lambda and SAM template to be triggered by path with variables:
```
TheFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: app.lambdaHandler
Runtime: nodejs8.10
Events:
Aliases:
Type: Api
Properties:
Path: /{product}/prefix_{type}_suffix/{id}.json
Method: get
```
Start local API and invoke URL `http://127.0.0.1:3000/good-stuff/prefix_type_A_suffix/123.json`
You can see that path parameters were successfully parsed:
```
console.log(event.pathParameters);
{ product: 'good-stuff', type: 'type_A', id: '123' }
```
But when trying to deploy such template to API Gateway you will get error `Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end.`
### Observed result
All works fine!
### Expected result
I'd expect SAM CLI to tell me that such format is not supported.
As a workaround, you have to define path like `/{product}/{param_with_type}/{id_with_extension}` and parse variables out of path parameters, or just setup proxy integration and parse path parts on you own (or by some framework which will do all the routing for you), which is fine as such path variables are not supported in AWS API Gateway now, as far as I know.
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
1. OS: Windows
2. `sam --version`: SAM CLI, version 0.11.0
Contributor guide
Assessment
This issue has not been assessed yet.