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 réponse
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

répondu il y a 5 mois
profile picture
EXPERT
vérifié il y a 5 mois
profile picture
EXPERT
Kallu
vérifié il y a 5 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions