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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ