How to manage ECS tasks with a Network Load Balancer in TypeScript?TypeScript
In this program, we create a network load balancer and an ECS task set using the AWS native Pulumi libraries. For this, we use the following resources:
aws-native.ecs.TaskSet: This resource describes a set of ECS tasks. An ECS task set is a subset of an ECS service's tasks that use a specific task definition version, container settings, and network settings.
aws-native.elasticloadbalancingv2.TargetGroup: A target group routes requests to one or more registered targets when it receives traffic from the load balancer.
aws-native.elasticloadbalancingv2.Listener: Before you start using your Network Load Balancer, you create one or more listeners. A Network Load Balancer listener listens for connection requests from clients.
Let's start coding:
This establishes a network load balancer listening on port 80 and balancing amongst ECS tasks. These tasks are running the
nginxDocker image. The ECS tasks are publicly reachable through the load balancer.
You can access the load balancer at its DNS name. The Pulumi Program exports this value.