목표: 다운타임 0에 가깝게 새 버전을 점진 배포하고, 문제시 즉시 롤백
도구: ALB(Target Group 가중치 분배) + ASG (+ 선택: CodeDeploy/CodePipeline)
Client → Route 53(Alias)
→ ALB(HTTPS 443 Listener)
└─ Target Group A (Blue ASG)
└─ Target Group B (Green ASG)
/healthz, 200 OK) 필수/healthz), ELB Health Check 사용ALB RequestCountPerTarget) + 적절한 WarmupCLI 예시 (ALB Listener 가중치 변경)
aws elbv2 modify-listener \
--listener-arn arn:aws:elasticloadbalancing:...:listener/app/my-alb/... \
--default-actions '[
{"Type":"forward",
"ForwardConfig":{
"TargetGroups":[
{"TargetGroupArn":"arn:...:targetgroup/tg-blue/...", "Weight":90},
{"TargetGroupArn":"arn:...:targetgroup/tg-green/...", "Weight":10}
]
}
}
]'
HTTPCode_Target_5XX_Count, TargetResponseTime, RequestCountPerTarget, 앱 오류율/canary 또는 x-canary: true) 으로 내부 사용자/테스터만 Green 사용주의: Stickiness가 켜져 있으면 분배 편향이 생길 수 있으니 Canary 구간에서는 Off 권장
CodeDeployDefault.AllAtOnce / Canary10Percent5Minutes / Linear10PercentEvery1Minute 등BeforeInstall / AfterInstall / AfterAllowTestTraffic / BeforeAllowTraffic / AfterAllowTrafficResources:
TgBlue:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
TargetType: instance
Protocol: HTTP
Port: 80
VpcId: vpc-xxxx
HealthCheckPath: /healthz
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '60' # API라 짧게
TgGreen:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
TargetType: instance
Protocol: HTTP
Port: 80
VpcId: vpc-xxxx
HealthCheckPath: /healthz
Alb:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Type: application
Subnets: [subnet-a, subnet-b]
SecurityGroups: [sg-alb]
Lsnr443:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
LoadBalancerArn: !Ref Alb
Port: 443
Protocol: HTTPS
Certificates: [{CertificateArn: arn:aws:acm:...}]
DefaultActions:
- Type: forward
ForwardConfig:
TargetGroups:
- TargetGroupArn: !Ref TgBlue
Weight: 100
- TargetGroupArn: !Ref TgGreen
Weight: 0
배포마다 ForwardConfig.Weight만 업데이트하면 Canary/Shift를 자동화할 수 있습니다.