AWS API Gateway - URL rewrite

0

My requirement is to rewrite url in API Gateway (REST API) . API Gateway (+ Lambda authorizer) --> VPC Link --> NLB--> (internal) ALB --> ECS For e.g. if my external facing url is "bookings/trains/7010" it needs to be rewritten as "bookings/clients/123/trains/7010" when calling backend url where I extract clients data from the encrypted token (during auth token validation) in Lambda authorizer. Is there way to do it in gateway?

VJ
asked a year ago1904 views
1 Answer
1
Accepted Answer

For an API Gateway operation like this:

/bookings/trains/{trainID}

Calling a backend API like this:

/bookings/clients/{clientID}/trains/{trainID}

The trainID Path Parameter, "7010", will map straight across to the Endpoint URL defined in your API Integration Request.

To get the clientID from your Lambda Custom Authorizer, you would need to make sure the authorizer returns the following context map:

"context" : {
  "clientID": "123"
}

Then implement a Request Mapping Template with the following line of code:

#set($context.requestOverride.path.clientID = $context.authorizer.clientID)
profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions