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

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

Bekir U
답변함 4달 전

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

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

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

관련 콘텐츠