I'm trying to make to work Load balancer with ECS.
The only way I could figure out how to connect ECS task to load balancer is to create a Target group for private IP of that task (seems that Fargate services don't have EC2 instances). It works alright until I redeploy container and task changes its IP.
Is there a way to permanently connect a task to load balancer even if the IP gets changed due new deployment?
You should connect the ECS service with the Load Balancer. The ECS service will then register/deregister the ECS task(s) with the load balancer.
Please read the documentation here.