Closed
Description
Use case
I have multiple API Gateway Rest apis backed by AWS Lambda.
I want to these APIs to the same Custom domain name with different paths.
For example I have APIs with these urls, each backed by a different lambda:
- https://xxx.execute-api.us-east-1.amazonaws.com/v1
- https://yyy.execute-api.us-east-1.amazonaws.com/v1
- https://xxx_test.execute-api.us-east-1.amazonaws.com/v1
- https://yyy_test.execute-api.us-east-1.amazonaws.com/v1
I want both of them to be available from:
- https://mydomain.com/api/v1/xxx
- https://mydomain.com/api/v1/yyy
- https://mydomain.com/api/test/xxx
- https://mydomain.com/api/test/yyy
respectively.
When Init-ing the APIGatewayRestResolver class I would have to pass in the strip_prefixes.
strip_prefixes=["/api/v1/xxx", "/api/test/xxx"]
We could potentials go to a high level of options due to combinatorics.
Solution/User Experience
- Use regex:
strip_prefixes=["^.*?xxx"]
- The path will be stripped of the prefixes one by one from left to right.
strip_prefixes=["api", "v1" ,"test","xxx"]
So if out initial path is /api/v1/xxx
it will strip "api" first:
/api/v1/xxx
-> /v1/xxx
Then v1
/v1/xxx
-> /xxx
Then it will try to strip "test" but nothing would change:
/xxx
- > /xxx
Then it will strip "xxx"
/xxx
- > /
Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped