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
demandé il y a un an1991 vues
1 réponse
1
Réponse acceptée

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
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions