Search code examples
amazon-web-servicesgitamazon-ec2github-actionsamazon-ecs

AWS ECS cluster task dynamic IP to static on Github action CI/CD


I've somehow managed to set up Git actions CI/CD to AWS ECS fargate, and it does work. But I have one problem for now, at first I could not find the url or ip for my app. I saw that it IS deployed, but I did not know where it is deployed. Then I figured out that there is task inside my cluster and the task has an ip. And it I can access it, but every time I redeploy my app, ip changes because there it new task created.

I've asked Chat GPT about it, it gave me a billion stupid answer, and one of "seems to work" was to create Application Load Balancer, but I have a problem with it, since it is fargate and I don't have any EC2 instances, I don't have anything to select in target group, so it is impossible to create ALB, I guess. But how I can get static ip so that I can add it to my domain?


Solution

  • I don't have anything to select in target group, so it is impossible to create ALB, I guess.

    You need to create an application load balancer, and associate it with the target group. The target group can be completely empty of targets at first, that is totally fine. An empty target group does not prevent you from creating a load balancer.

    After you have the ALB and Target Group created, you would configure your ECS service to use the load balancer/target group. At that point the ECS service itself will automatically register your ECS tasks with the load balancer, and automatically deregister then when they are removed.