Paul Williams
Paul Williams

Reputation: 17020

How to overwrite path on route to send to same integration using AWS API Gateway UI

I am trying to test changes to an AWS API Gateway. Currently, our AWS API Gateway has the following path setup:

ANY /{proxy+}

This path routes to the backend integration which is an Elastic Container Service. The ECS service has hundreds of controllers for various business needs. A typical call would look somethiung like this:

GET /api/controller/1

Currently, there is a single API Gateway route with a greedy variable to handle all of the requests:

ANY /{proxy+}

I would like to setup a new endpoint called /test which maps directly to the above endpoints. The gateway should strip the /test base path and pass the altered path to the integration.

For example, if the following request is sent to the API Gateway, and it hits the new test endpoint:

GET /test/api/controller/1

I want this call to strip the /test base path and forward the query with the replaced path:

GET /api/controller/1

I created a separate route and set this to go to the same integration:

ANY /test/{proxy+}

I have configured the same integration for this route. I have not figured out how to strip the /test base path from the request before sending it to the integration. Is there a way to strip a base path seamlessly from incoming requests?

I would prefer to use the AWS API Gateway UI, if possible. It seems like this should be possible with parameter mappings, for example, but I have not yet figured out how to make it happen.

Upvotes: 4

Views: 2052

Answers (1)

TJ L
TJ L

Reputation: 21

I am using AWS API Gateway's HTTP API, and I'm looking for a way to override route keys similar to what you're doing. I have solved the issue using this approach: by overwriting the request path with "proxy," I can pass the non-route path as an integrated endpoint.

aws apigateway ui image

Upvotes: 2

Related Questions