silentsilence
silentsilence

Reputation: 31

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?

Upvotes: 3

Views: 3304

Answers (3)

R Zaara
R Zaara

Reputation: 1

Hi just to share my experience. Even if you use v2, you'll end up compromising mTLS as mTLS domain resource will error due to inconsistency b/w v1 and v2. It's a loop which I haven't figured out yet.

Upvotes: 0

Paul Michalik
Paul Michalik

Reputation: 4381

One does not. Unfortunately, as of today this is still not supported by AWS::ApiGateway::RestAPI resource type.

Upvotes: 1

ebol2000
ebol2000

Reputation: 1283

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.

Upvotes: 1

Related Questions