'How does one create multi-level base path mapping for REST APIs on AWS API gateway?
I am currently trying to use aws api gateway CLI to create a multi-level base path mapping. I am running the following command:
aws apigateway create-base-path-mapping \
--domain-name example.com --base-path orders/v2 \
--rest-api-id abcd --stage production
which gives me an error:
An error occurred (
BadRequestException) when calling the CreateBasePathMapping operation: 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.
This is inconsistent with https://aws.amazon.com/blogs/compute/using-multiple-segments-in-amazon-api-gateway-base-path-mapping/ which states for REST Api's use API Gateway V1. When trying to use API Gateway V2 we get an error stating it can only be used for HTTP API's.
How does one create a multi-level base path mapping for REST APIs?
Solution 1:[1]
I ran into this article which indicates you will need to call the apigatewayv2 call. The interesting thing is that the V2 is only supported (it seems) for Regional endpoints, not Edge endpoints. If you have a regional one you can call:
aws apigatewayv2 create-api-mapping /
--domain-name domain.com --api-mapping-key orders/v2 /
--api-id abcd --stage production
The error I get when trying to run the above against the Edge endpoint is
An error occurred (BadRequestException) when calling the CreateApiMapping operation: 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 was looking here for answers https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-edge-optimized-custom-domain-name.html#how-to-custom-domains-mapping-console
... but no mention of unsupported "/" base path characters sadly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
