How to Migrate Classic Load Balancer to Application Load Balancer

TL;DR
- You don't rebuild anything: create the ALB beside the CLB, register the same instances, then move Route 53 weighted records 5% → 50% → 100%. Rollback is one record change and about 60 seconds of propagation at TTL 60.
- Failures land in three predictable places — health checks pointed at a URL that answers
301, app code readingREMOTE_ADDRinstead ofX-Forwarded-For, and security groups that never had to allow the ALB's subnets. - If you need raw TCP passthrough, a static IP per AZ, or PrivateLink, ALB is the wrong target; stay on CLB or move to NLB.
A CLB isn't broken — it's just out of upgrades
As of 2026-02, Classic Load Balancers still serve traffic and AWS has not announced a shutdown. So this is rarely an emergency migration; it's a capability migration. You move when the feature list starts costing you money or engineering hours, not because the old thing stopped working.
The triggers I look for: you want to send /api/* to one group of instances and / to another, and you're currently doing it with two CLBs and a lot of regret. Or you need more than one certificate on 443 — a CLB takes exactly one cert per listener port, no SNI, so a second domain means a second load balancer. Or you want AWS WAF (v2) attached directly, and CLB only ever supported the retired WAF Classic.
| What you need | CLB | ALB |
|---|---|---|
| Host / path / header routing | No — one backend per port | Listener rules on host, path, header, method |
| HTTP/2 to clients | No | Yes |
| Multiple certs on 443 | One cert per port | Up to 25 certs via SNI |
| AWS WAF (v2) | Not supported | Web ACL attached to the ALB |
| Per-target health detail | Coarse | TargetResponseTime, per-target health state |
| gRPC | No | Yes (HTTP/2 target groups) |
| Static IP address | No | No — put an NLB in front if you need one |
| Billing shape | Hourly + GB processed | Hourly + LCU (connections, bytes, rule evaluations) |
The metrics gap matters more than people expect. On a CLB you get Latency and HTTPCode_Backend_5XX_Count — aggregate, no clue which instance is sick. On an ALB, describe-target-health tells you exactly which target is unhealthy and why, in a sentence.
When ALB is the wrong answer
Don't run this migration if your CLB listener is TCP or SSL passthrough and the backend speaks a protocol ALB can't parse — MySQL on 3306, MQTT, arbitrary binary framing. ALB will open the connection and then sit there confused. That's NLB work.
Skip it too if the CLB is single-AZ. An internet-facing ALB needs at least two subnets in two AZs, so a cheap single-AZ setup becomes a real architecture change with real cost. And if you're on a fixed budget where the CLB's per-GB billing is genuinely cheaper at your traffic volume, measure first — an ALB with heavy rule evaluation can run more than a quiet CLB.
The mapping: what each CLB object becomes
Almost every migration surprise comes from translating these one-to-one when they aren't.
| CLB object | ALB equivalent | Gotcha |
|---|---|---|
| Listener on port 80/443 | Listener + default action | Every listener needs a default action, even if rules never miss |
| Registered instances | Target group (instance / IP / Lambda) | Same instance can sit in many target groups |
| Health check (TCP or HTTP) | Per-target-group health check | Matcher defaults to 200 only; no redirect following |
| Sticky sessions | Target group stickiness | Cookie is AWSALB, duration 1s–7 days |
| Cross-zone balancing toggle | Always on | You cannot disable it on ALB |
| SSL certificate | ACM cert on the listener | Cert must be in the same region as the ALB |
| Access logs | S3 bucket + bucket policy | The bucket policy is a separate, easily-forgotten step |
Phase 1: stand up the ALB at 5% of traffic
Same VPC, same subnets as the instances, new security group. Build the target group first so the listener has something to attach to.
aws elbv2 create-target-group
--name app-tg-prod
--protocol HTTP --port 80
--vpc-id vpc-0a1b2c3d4e5f67890
--target-type instance
--health-check-path /healthz
--health-check-interval-seconds 15
--healthy-threshold-count 2
--unhealthy-threshold-count 3
--matcher HttpCode=200
--region us-east-1
aws elbv2 register-targets
--target-group-arn arn:aws:elasticloadbalancing:us-east-1:111122223333:targetgroup/app-tg-prod/9f2c1a77e0b4d111
--targets Id=i-0abc123def4567890 Id=i-0def456abc1237890
aws elbv2 describe-target-health
--target-group-arn arn:aws:elasticloadbalancing:us-east-1:111122223333:targetgroup/app-tg-prod/9f2c1a77e0b4d111
--query 'TargetHealthDescriptions[].TargetHealth.[State,Reason]' --output table
Do not reuse a CLB health check path you've never actually inspected with `curl -I`. More on that below — it's the single most common cutover failure. If the app has no cheap health endpoint, add one now that returns 200 without touching the database.
In Terraform, pin the settings you'll otherwise forget: `deregistration_delay = 30` (the default 300 makes every deploy feel hung) and `idle_timeout = 65`, which needs to sit *above* your app's keep-alive timeout or you get sporadic `504`s that only show up in the ALB access logs.
```hcl
resource "aws_lb" "app" {
name = "app-alb-prod"
load_balancer_type = "application"
security_groups = [aws_security_group.alb.id]
subnets = var.public_subnet_ids
idle_timeout = 65
access_logs {
bucket = aws_s3_bucket.lb_logs.id
prefix = "app-alb"
enabled = true
}
}
resource "aws_lb_target_group" "app" {
name = "app-tg-prod"
port = 80
protocol = "HTTP"
vpc_id = var.vpc_id
deregistration_delay = 30
health_check {
path = "/healthz"
matcher = "200"
interval = 15
timeout = 5
healthy_threshold = 2
unhealthy_threshold = 3
}
}
Trigger to move to Phase 2: five consecutive days at 5% traffic with zero `HTTPCode_Target_5XX_Count` that the CLB didn't also produce, and p95 `TargetResponseTime` within ~10 ms of the CLB baseline.
## Phase 2: TLS, WAF, and logs
Terminate TLS on the ALB with an ACM cert, redirect 80 → 443 with a listener rule rather than app code, and attach the web ACL. Then turn on access logs — and expect the bucket policy to fight you. The console will happily create the ALB and quietly fail to deliver logs if the policy doesn't grant `elasticloadbalancing.amazonaws.com` write access, and the error surfaces as `Access Denied for bucket: my-lb-logs. Please check S3bucket permission` in the ALB attributes, days later, when you go looking for logs that were never there.
Phase 2 is also where the `X-Forwarded-For` work happens. Anything that rate-limits, geo-locates, or writes audit rows using the client IP needs to read the first entry of `X-Forwarded-For` (or `X-Forwarded-Proto` for scheme checks). Otherwise every request in your logs looks like it came from a 10.0.x.x address and your brute-force blocker locks out nobody.
## The 02:47 cutover that returned 503s
The migration I remember best ran at 02:47 on a Tuesday for a PHP app on two `m5.large` instances in us-east-1. The CLB health check was plain `TCP:80` — it only ever asked "is the port open". I pointed the new target group at `/` with matcher `200`, which felt equivalent.
Forty-five seconds after the DNS weight moved, the ALB started returning `503 Service Temporarily Unavailable` for everything. Both targets were unhealthy:
```json
{
"TargetHealth": {
"State": "unhealthy",
"Reason": "Target.ResponseCodeMismatch",
"Description": "Health checks failed with these codes: [301]"
}
}
The app forced HTTPS with a 301 on `/`. ALB health checks don't follow redirects, so a healthy app looked dead. The first configuration got the matcher wrong by assuming HTTP semantics transfer; a CLB TCP check never encoded that assumption in the first place.
Diagnosis was `describe-target-health` plus `curl -I http://10.0.2.14/` from a bastion, which showed the 301 immediately. The fix was a `/healthz` route returning a bare 200 with no DB call — not a `200-399` matcher, which would have hidden real auth redirects. Verified by polling health every 5 seconds
Leave a Reply