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?

1개 답변
1
수락된 답변

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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인