amazon-web-servicesamazon-ecsaws-fargatenlbaws-elb

Correct order of creation: AWS Fargate, NLB and Target group?


What should be the order for creation of an AWS Fargate Service along with a Internet-facing Network Load Balancer?

The service requires an NLB to be created, NLB requires a Target group, and the target group requires the service I guess.

I am trying to perform this through console as of now before moving to CloudFormation.

Found a similar question that does not answer my question: AWS Fargate: Create service with target group for load balancer


Solution

  • The service requires an NLB to be created, NLB requires a Target group, and the target group requires the service I guess.

    This is incorrect. The target group doesn't require a service. You can create a target group with 0 targets to start with.

    Also, you don't ever point a target group at an ECS service directly anyway. You configure the ECS service with knowledge of the load balancer/target group, and the service automatically adds ECS task instances to the target group and removes them, as it creates and deletes tasks.

    So order of creation would be Target Group, NLB, then Service.


    If you just went ahead and used CloudFormation like you are intending to do, then you would not have to worry about order of creation at all, as that is one of the things CloudFormation handles for you.