Error: 'loadBalancerCanonicalHostedZoneId' was not provided when constructing Network Load Balancer MyLoadBalancerStack/my--test-nlb from attributes.

0

Hi, I need to create one ARecord with network load balancer but I am getting this issue -- Error: 'loadBalancerCanonicalHostedZoneId' was not provided when constructing Network Load Balancer MyLoadBalancerStack/my--test-nlb from attributes

I have used the following code --

............... const ssmParameters = mySSMParameters(); const nlb = NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(this, my--test-nlb, { loadBalancerArn: ssmParameters.nlbArn });

new ARecord(this, my-api-ARecord, { zone: hostedZone, recordName: recordName, target: RecordTarget.fromAlias(new LoadBalancerTarget(nlb)) });

Please help with your valuable suggestions. Thank you!

1 Answer
0

Here's a more complete example of how to import a network load balancer:

const nlb = NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(this, 'my-test-nlb', {
  loadBalancerArn: ssmParameters.nlbArn,
  loadBalancerCanonicalHostedZoneId: 'YourHostedZoneID'
});

Then you can proceed to create your ARecord as you have in your code.

For examples you can check this link out https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.NetworkLoadBalancer.html

answered 4 months ago
profile picture
EXPERT
reviewed 4 months ago
profile picture
EXPERT
Kallu
reviewed 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions