aws-route53-targets: LoadBalancerTarget always appends the `dualstack` prefix even when not a valid option
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### What is the problem?
When fixing https://github.com/aws/aws-cdk/issues/6271 with https://github.com/aws/aws-cdk/pull/8747, you enforced that all load balancer targets start with the `dualstack` prefix. Network Load Balancers (NLBs) have 2 IP Address types you can configure, IPv4 or dualstack (this was launched [late last year](https://aws.amazon.com/about-aws/whats-new/2020/11/network-load-balancer-supports-ipv6/)). The default for the property is IPv4, and the [CDK definition](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-elasticloadbalancingv2.NetworkLoadBalancerProps.html) doesn't even allow for the option to be set. When NLB is set to IPv4, it does not have a dualstack prefix you can route to. This means the generated ARecords don't work; they target a non-existent DNS record.
### Reproduction Steps
I'm going to leave the class instantiation out, but you can assume this is within a construct.
```
this.hostedZone = new route53.HostedZone(this, "ExampleHostedZone", {
zoneName: props.hostedZoneName,
});
this.vpc = new ec2.Vpc(this, "ExampleVPC");
this.loadBalancer = new elasticloadbalancingv2.NetworkLoadBalancer(this, "ExampleNLB", {
vpc: this.vpc,
});
new aws-route53.ARecord(this,
"LoadBalancerAlias",
{
zone: this.hostedZone,
target: aws-route53.RecordTarget.fromAlias(
new aws-route53-targets.LoadBalancerTarget(this.loadBalancer)
),
comment: "A-Record to route traffic to the service Load Balancer",
}
);
```
### What did you expect to happen?
I expected a valid Alias ARecord to my NLB.
### What actually happened?
The CDK incorrectly prefixed `dualstack` to my NLB DNS name, causing the service to be unreachable.
### CDK CLI Version
1.125.0
### Framework Version
_No response_
### Node.js Version
12
### OS
AmazonLinux 2
### Language
Typescript
### Language Version
_No response_
### Other information
The NLB IPAddressType is a configurable property of the Cfn definition https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-loadbalancer.html#cfn-elasticloadbalancingv2-loadbalancer-ipaddresstype
Contributor guide
Assessment
This issue has not been assessed yet.