EC2 ALB - ECS Service 연결
✅ EC2 ALB Target Group 생성
aws elbv2 create-target-group \ --name ecs-kbsec-ai-insight-front-tg \ --protocol HTTP \ --port 4500 \ --vpc-id vpc-063ea85b9ec96670d \ --target-type ip \ --health-check-protocol HTTP \ --health-check-port traffic-port \ --health-check-path / \ --region ap-northeast-2
{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:ap-northeast-2:104871657422:targetgroup/ecs-kbsec-ai-insight-front-tg/cdf21368578706fb", "TargetGroupName": "ecs-kbsec-ai-insight-front-tg", "Protocol": "HTTP", "Port": 4500, "VpcId": "vpc-063ea85b9ec96670d", "HealthCheckProtocol": "HTTP", "HealthCheckPort": "traffic-port", "HealthCheckEnabled": true, "HealthCheckIntervalSeconds": 30, "HealthCheckTimeoutSeconds": 5, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "HealthCheckPath": "/", "Matcher": { "HttpCode": "200" }, "TargetType": "ip", "ProtocolVersion": "HTTP1", "IpAddressType": "ipv4" } ] }
🔧 ALB 리스너에 Target Group 연결하기 AWS 콘솔 → EC2 > Load Balancers ks2-kai-dev-kabie-ecs-alb 클릭 Listeners 탭 > 포트 80 > View/edit rules 기존 Rule 수정 또는 새 Rule 추가: IF path is / → THEN forward to insight-agent-front-tg 또는 기본 rule 수정: “default action” → forward to insight-agent-front-tg 설정 후 "Save" 클릭
✅ 기존 ECS에 ALB 설정 (GUI로 지원 안되니, CLI로 강제 업데이트)
aws ecs update-service \ --cluster kbsec-ai-cluster \ --service insight-agent-front \ --load-balancers "targetGroupArn=arn:aws:elasticloadbalancing:ap-northeast-2:104871657422:targetgroup/ecs-kbsec-ai-insight-front-tg/cdf21368578706fb,containerName=insight-agent-front,containerPort=4500" \ --region ap-northeast-2