AWS ECS WITH NLB AND API GATEWAY

0

I have a spring boot application in the ecs fargate within a private subnet. I have configured NAT gateways for my 2 subnets. I would like to build and connect to a REST API. I have a network load balancer attached to my fargate service

  1. how do I configure health checks for my springboot microservices using network load balancer
  2. how do I go about the architecture design
3 Answers
0

Hi, what is the reason of choosing a Network load balancer?. You are missing a service to make this solution viable. ALB is usually a more straightforward solution. However, here some remarks of using either NLB or ALB are that If you use an ALB then the API Gateway cannot be associated with an IP address or a security group, which means it is not possible to associate an API Gateway with an inbound rule. So ALB can not filter request by inbound rule. In addition, API Gateway's VPC link only supports NLB, which means API Gateway cannot specify ALB as forwarded target which is more suitable for an REST API integration. The solution, you must consume services through an API Gateway, VPC link, NLB and finally reach you container on ECS. Here an example of how to do it: https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-with-private-integration.html

  1. For the health-checks configuration. Create an ECS Service. Choose Fargate launch type. When you configure network, make sure you use the VPC where your resources were deployed, choose your 2 private subnets, leave Auto-assign public IP enabled and use your NLB. Then, copy the tasks' private IP addresses (your subnets). Then go to Load Balancer Listeners, add the IP addresses to Network Load Balancer targets. Reminder: Service is for long running applications while task is ideal for short running jobs. Service can be configured to use a load balancer while task cannot.
profile pictureAWS
answered a year ago
  • Can one add rules to the NLB after creating it? I have tried and there are no rule options on NLB the way ALB has so when I grab the Tasks IP addresses there is no way to add them

0

Yes, this is done in the target group first, not in the load balancer. First, go to your target group, you need to update your target group, you must have chosen IP address as the target type, then in the targets tab click register target and here you add your IPs. After that, go to your NLB, in the Listeners tab click Edit listener and here you must select your target group. Or you can add a new listener as you prefer it or need it.

profile pictureAWS
answered a year ago
0

@Vicky, how about this constellation? API Gateway (Rest API) -> NLB -> ALB -> ECS Fargate.

Bekir U
answered 6 months 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