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 個回答
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

已回答 5 個月前
profile picture
專家
已審閱 5 個月前
profile picture
專家
Kallu
已審閱 5 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南