Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(NLB): NetworkLoadBalancer.fromLookup returning dummy NLBs #26463

Closed
vneekhra opened this issue Jul 21, 2023 · 4 comments
Closed

(NLB): NetworkLoadBalancer.fromLookup returning dummy NLBs #26463

vneekhra opened this issue Jul 21, 2023 · 4 comments
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2

Comments

@vneekhra
Copy link

Describe the bug

I am trying to fetch the NLB using its tags and using below method to fetch it.

`const nlb = this.getNLBByTag(tagNLB, props);

this.link = new VpcLink(this, app-${props.stage}-vpclink, {
targets: [nlb],
});

private getNLBByTag(tag: string, props: APPDomainVPCStackProps): INetworkLoadBalancer{
const nlbOptions: NetworkLoadBalancerLookupOptions = {
loadBalancerTags: {
component: "apigw",
application: "app",
env: "dev"
},
};
return NetworkLoadBalancer.fromLookup(this, app-${props.stage}-nlb, nlbOptions);
}`

Now this NetworkLoadBalancer.fromLookup method seems returning three results as below

  1. arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/network/my-load-balancer/50dc6c495c0c9188
  2. arn:aws:elasticloadbalancing:us-east-2::loadbalancer/net/b72e485999b754299ae2067c2c1b3747/3eb24f395333b0d4
  3. arn:aws:elasticloadbalancing:us-east-2::loadbalancer/net/b72e485999b754299ae2067c2c1b3747/3eb24f395333b0d4

Not sure why it is returning "my-load-balancer" nlb, even though it is not there in any of the AWS account and region.
Then for 2nd arn, it is showing dummy AZs: availabilityZones: [ 'dummy1a', 'dummy1b' ]
for 3rd arn: it is correct and that is what I am expecting. But ideally fromLookup method should only return one arn.

also in cdk.context.json file, I can only see one actual NLB, not any other dummy NLBs.
I am not checking-in this file cdk.context.json in git.

Expected Behavior

It should return only one arn which is mentioned in point #3 in describe section

Current Behavior

this NetworkLoadBalancer.fromLookup method returning three results as below

  1. arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/network/my-load-balancer/50dc6c495c0c9188
  2. arn:aws:elasticloadbalancing:us-east-2::loadbalancer/net/b72e485999b754299ae2067c2c1b3747/3eb24f395333b0d4
  3. arn:aws:elasticloadbalancing:us-east-2::loadbalancer/net/b72e485999b754299ae2067c2c1b3747/3eb24f395333b0d4

Reproduction Steps

npm install
cdk synth "" -c stage=$ENV
cdk deploy "
" -c stage=$ENV --require-approval never

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.86.0

Framework Version

No response

Node.js Version

18

OS

Linux

Language

Typescript

Language Version

No response

Other information

Should we check-in cdk.context.json file in git?
Since I am running the cdk code using pipeline, that's why I have not committed cdk.context.json file, but I can see that the file is getting created and which has only one NLB and other vpc and subnet info.

@vneekhra vneekhra added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 21, 2023
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Jul 21, 2023
@khushail khushail self-assigned this Jul 21, 2023
@khushail khushail added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jul 21, 2023
@peterwoodworth
Copy link
Contributor

peterwoodworth commented Jul 21, 2023

Should we check-in cdk.context.json file in git?

Yes

See also best practices "Commit cdk.context.json"

@peterwoodworth peterwoodworth removed needs-triage This issue or PR still needs to be triaged. bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jul 21, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@khushail khushail removed their assignment Jul 21, 2023
@vneekhra
Copy link
Author

@peterwoodworth did you check the issue I mentioned in the bug section? why the method NetworkLoadBalancer.fromLookup is returning 3 results? and what could be the possible work around?

@peterwoodworth
Copy link
Contributor

I don't know what you mean by "returning three results". I took it to mean that one of those three results can occur any time you run this, in which case this would be easily solved by committing the cdk.context.json as you state that is functioning correctly, and our documentation I linked states you might get inconsistent behavior in a pipeline environment. If you're seeing three results at once, I'm not really sure how or what that means.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2
Projects
None yet
Development

No branches or pull requests

3 participants