Thursday, 4 December 2025

ECS service and target group

  • associate ECS service to load balancer
  • define target group for load balancer
  • running tasks of this ECS service become targets of this target group
#cloudformation template snippet
Service:
    Type: "AWS::ECS::Service"
    Properties:
      Cluster: !FindInMap [BuildEnvironment, !Ref 'EnvironmentType', "cluster"]
      DesiredCount: !FindInMap [BuildEnvironment, !Ref 'EnvironmentType', "desire"]
      LoadBalancers:
        - ContainerName: !Sub "${EnvironmentType}-${APP}"
          ContainerPort: 80
          TargetGroupArn: my_target_group_arn

See targets in a target group

  1. Go to EC2
  2. In left side, under Load Balancing. Click Target Groups link
  3. Search target group by name. Click that target group
  4. In Registered targets section, see targets. They are running tasks. Find port
  5. Go to a task. Check the Network bindings for the task to find port. These ports are matched.

No comments:

Post a Comment