3
votes

I have a VPC with public and private subnets. NLB is deployed to a private subnet, and it has 5 listeners.

port 9000 forwarding to targetgroup-01
port 9001 forwarding to targetgroup-02
and so on.

Created a VPC link in API gateway pointed to NLB

How do I configure API's to route the request to a specific target group on NLB? In the Integration point for the VPC link, I see only the option to specify the VPC link and endpoint. If it is the endpoint, what is the format of the endpoint URL to route to the specific target group?

or Do I have to create an NLB for each microservice?

2

2 Answers

2
votes

API Gateway will forward any custom port over 1024, so your routing will be dependent on what port you call your api endpoint on.

Eg.

https://your-apigateway-endpoint.amazonaws.com:9000 --> NLB -> Target Group 01

https://your-apigateway-endpoint.amazonaws.com:9001 --> NLB -> Target Group 01

If you are using Proxy Integration (as per the documentation), any path after the url (above) will be passed to the instance behind your target group.

Eg. https://your-apigateway-endpoint.amazonaws.com:9000/test --> NLB --> (your instance in Target Group 1)/test

https://your-apigateway-endpoint.amazonaws.com:9001/test --> NLB --> (your instance in Target Group 2)/test

Hope this helps :)