Skip to content

Commit cba95b8

Browse files
committed
improve(route53-targets): enhance code clarity and type safety
- Add explanatory comment for constructor name checking approach - Improve variable naming and formatting in isIpv4Only method - Better explain why NLB vs ALB detection is needed for DNS requirements
1 parent ee4fab5 commit cba95b8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/aws-cdk-lib/aws-route53-targets/lib/load-balancer-target.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ export class LoadBalancerTarget implements route53.IAliasRecordTarget {
2828
}
2929

3030
private isNetworkLoadBalancer(): boolean {
31-
// Check if this has the NLB-specific properties/methods
32-
// NLBs have addListener method that returns NetworkListener, ALBs return ApplicationListener
33-
// We'll use a duck-typing approach by checking the constructor name
34-
return this.loadBalancer.constructor.name === 'NetworkLoadBalancer' ||
31+
// We use constructor name checking as a reliable way to detect NLB vs ALB
32+
// since both implement ILoadBalancerV2 but have different DNS requirements
33+
return this.loadBalancer.constructor.name === 'NetworkLoadBalancer' ||
3534
this.loadBalancer.constructor.name === 'LookedUpNetworkLoadBalancer';
3635
}
3736

3837
private isIpv4Only(): boolean {
39-
const ipAddressType = (this.loadBalancer as any).ipAddressType;
40-
return ipAddressType === elbv2.IpAddressType.IPV4 || ipAddressType === undefined;
38+
const lb = this.loadBalancer as any;
39+
return lb.ipAddressType === elbv2.IpAddressType.IPV4 ||
40+
lb.ipAddressType === undefined;
4141
}
4242
}

0 commit comments

Comments
 (0)