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

(aws-elasticloadbalancingv2): AlbTarget does not accept an instance of IApplicationLoadBalancer #27466

Closed
shadab16 opened this issue Oct 9, 2023 · 2 comments · Fixed by #27516
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p1

Comments

@shadab16
Copy link

shadab16 commented Oct 9, 2023

Describe the bug

AlbTarget does not accept an instance of IApplicationLoadBalancer. This prevents it from being used alongside ApplicationLoadBalancer.fromLookup and ApplicationLoadBalancer.fromApplicationLoadBalancerAttributes because of their return type.

Workaround is to use AlbArnTarget directly.

Expected Behavior

No compilation error.

Current Behavior

Compilation error
error TS2345: Argument of type 'IApplicationLoadBalancer' is not assignable to parameter of type 'ApplicationLoadBalancer'.

Reproduction Steps

import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
import { AlbTarget } from 'aws-cdk-lib/aws-elasticloadbalancingv2-targets';

const testingAlb = elbv2.ApplicationLoadBalancer.fromLookup(this, 'TestingAlb', {
  loadBalancerTags: { Products: '...' }
});

const albTarget = new AlbTarget(testingAlb, 80);
                                ~~~~~~~~~~

Possible Solution

Constructor for AlbTarget can be changed to accept interface IApplicationLoadBalancer. The implementation only references loadBalancerArn from the given object, which is available in the interface too.

Additional Information/Context

No response

CDK CLI Version

2.100.0 (build e1b5c77)

Framework Version

No response

Node.js Version

v18.18.0

OS

Windows 10 22H2, WSL (5.15.90.1-microsoft-standard-WSL2)

Language

TypeScript

Language Version

5.2.2

Other information

No response

@shadab16 shadab16 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 9, 2023
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Oct 9, 2023
@peterwoodworth peterwoodworth added good first issue Related to contributions. See CONTRIBUTING.md p1 feature-request A feature should be added or improved. effort/small Small work item – less than a day of effort and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 9, 2023
@peterwoodworth
Copy link
Contributor

Thanks for reporting this issue, this makes sense

SarthakPaneru added a commit to SarthakPaneru/aws-cdk that referenced this issue Oct 11, 2023
@mergify mergify bot closed this as completed in #27516 Oct 18, 2023
mergify bot pushed a commit that referenced this issue Oct 18, 2023
#27516)

This PR for elasticloadbalancingv2-targets is to change Constructor for AlbTarget to accept interface IApplicationLoadBalancer instead of ApplicationLoadBalancer. This helps it from being used alongside ApplicationLoadBalancer.fromLookup and ApplicationLoadBalancer.fromApplicationLoadBalancerAttributes.

Closes #27466.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@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.

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 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants