question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws-route53-targets: LoadBalancerTarget always appends the `dualstack` prefix even when not a valid option

See original GitHub issue

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). The default for the property is IPv4, and the CDK definition 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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
epalace510commented, Dec 6, 2021

@larryboymi I wrote a class to do what I needed. It’s not my preferred solution, but it unblocked me.

import { AliasRecordTargetConfig, IAliasRecordTarget, IHostedZone, IRecordSet } from "monocdk/aws-route53";
import { NetworkLoadBalancer } from "monocdk/aws-elasticloadbalancingv2";

/**
 * Use an ELB Network Load Balancer as an alias record target.
 * This NLB specific target was written because CDK will always prepend
 * `dualstack` to the DNS name which is not always valid for NLBs.
 * https://github.com/aws/aws-cdk/issues/16987
 */
export class NetworkLoadBalancerTarget implements IAliasRecordTarget {
    private readonly loadBalancer: NetworkLoadBalancer;

    constructor(loadBalancer: NetworkLoadBalancer) {
      this.loadBalancer = loadBalancer;
    }

    /**
     * Return hosted zone ID and DNS name, usable for Route53 alias targets.
     */
    bind(_record: IRecordSet, _zone?: IHostedZone): AliasRecordTargetConfig {
      return {
        hostedZoneId: this.loadBalancer.loadBalancerCanonicalHostedZoneId,
        dnsName: this.loadBalancer.loadBalancerDnsName,
      };
    }
}

0reactions
github-actions[bot]commented, Dec 24, 2022

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Route53 A/AAAA Alias Record to ELB does not use "dualstack ...
When creating an ALIAS A/AAAA record in Route53 pointing to an ELB on the Web Console, the name will always have a "dualstack"...
Read more >
What does the dualstack prefix mean in AWS ELB?
The dualstack DNS name returns both IPv6 and IPv4 records for an EC2-Classic (Internet-facing, non-VPC) Elastic Load Balancer.
Read more >
@aws-cdk/aws-route53-targets | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Configure a load balancer to work with IPv6 addresses
Update the IP address type to "dualstack" using the AWS CLI. Run this command: aws elbv2 set-ip-address-type --load-balancer-arn <value> -- ...
Read more >
Vulkan validation error in vkCmdCopyBufferToImage - IssueHint
aws-route53-targets : LoadBalancerTarget always appends the `dualstack` prefix even when not a valid option, 5, 2021-10-14, 2022-10-25.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found