(aws-apigateway v1): Support for multi-level paths in BasePathMapping
See original GitHub issueI would like to have the possibility to add a multi-level path in BasePathMapping for Api gateway v1, as already stated in #14822 (but closed in favour of a new feature request like this)
Use Case
The specific case I’m trying to cover is:
- edge optimized domain name
- edge REST api endpoint
- multi-level path mapping
We are using apigateway v1
Proposed Solution
I tried a couple of workarounds:
Tried to use v1 BasePathMapping
but got this error:
Mapping API Gateway V1 doesn't support the slash character (/) in base path mappings. To create a multi-level base path mapping, use API Gateway V2.
Tried to switch to v2 with CfnApiMapping
and got this error:
Mapping Only REGIONAL domain names can be managed through the API Gateway V2 API. For EDGE domain names, please use the API Gateway V1 API. Also note that only REST APIs can be attached to EDGE domain names.
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 2 years ago
- Reactions:25
- Comments:10 (4 by maintainers)
Top GitHub Comments
+1 on supporting this on v1.
This isn’t quite right. Here’s what’s supported by APIGateway for RestAPI - you can create a multi-part mapping if the following conditions are met:
This error message:
Is an indication that condition 3 is not met. That is, you are trying to add a multipart mapping via apigateway v1’s base path mapping, which is not supported. The reason that adding the mapping from the console succeeds is because it is adding an apigatewayv2 apiMapping to your RestApi(apigatewayv1), which is supported, though this is not transparent.
So assuming other conditions are met, you can attach a multipart apigatewayv2 api mapping to your restApi/domainname. However, you will need to use the L1 (Cfn) constructs or roll your own adapter since the L2 constructs for apigateway and apigatewayv2 are not interoperable here.
It seems like it may make sense to build support for this use case in the L2 constructs. Some possible approaches:
DomainName.addBasePathMapping
to support creating apigatewayv2 ApiMappings either explicitly through an additional config or implicitly for multipart use caseDomainName.addApiMapping
to support adding v2 mapping to v1 api+domainnameHowever, the original feature request looks to be about specifically allowing for multipart mappings for edge api/domain which is a limitation of ApiGateway, not a limitation of CDK or CFN, so I don’t think that can be solved here.