elasticloadbalancingv2:Cannot construct AlbListenerTarget using lookUp
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
Constructing AlbListenerTarget with Listener fromLookup fails:
```
alb = aws_cdk.aws_elasticloadbalancingv2.ApplicationLoadBalancer.from_lookup(
self,
'ApplicationBalancer',
load_balancer_tags={
'elasticbeanstalk:environment-name': 'myenv'})
logging.info(f'found alb with arn <{alb.load_balancer_arn}>')
aws_elasticloadbalancingv2_targets.AlbTarget(alb=alb, port=80)
listener = ApplicationListener.from_lookup(self, 'ApplicationListener',
load_balancer_arn=alb.load_balancer_arn, listener_port=80)
logging.info(f'found listener with arn <{listener.listener_arn}>')
alb_target = aws_elasticloadbalancingv2_targets.AlbListenerTarget(listener)
```
==>
```
2025-01-29 05:32:38 INFO found alb with arn
2025-01-29 05:32:38 INFO found listener with arn
(....)py", line 62, in get_alb_listener
alb_target = aws_elasticloadbalancingv2_targets.AlbListenerTarget(listener)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/jsii/_runtime.py", line 118, in __call__
inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/aws_cdk/aws_elasticloadbalancingv2_targets/__init__.py", line 157, in __init__
check_type(argname="argument alb_listener", value=alb_listener, expected_type=type_hints["alb_listener"])
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/aws_cdk/aws_elasticloadbalancingv2_targets/__init__.py", line 25, in check_type
return typeguard.check_type(argname=argname, value=value, expected_type=expected_type) # type:ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.pyenv/versions/3.11.11/lib/python3.11/site-packages/typeguard/__init__.py", line 785, in check_type
raise TypeError(
TypeError: type of argument alb_listener must be aws_cdk.aws_elasticloadbalancingv2.ApplicationListener; got jsii._reference_map.InterfaceDynamicProxy instead
```
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Version
_No response_
### Expected Behavior
it should be possible to construct the listener.
### Current Behavior
cosntruction fails due to type-problems.
### Reproduction Steps
it should be possible to reproduce with the code above.
we have to switch wo `AlbListenerTarget` because of deprecation of `AlbTarget`.
As you can see in the code `AlbTarget` works (in production here) fine with the 'ApplicationLoadBalancer.from_lookup', so the ALB and also the listeners are in place.
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.166.0
### Framework Version
_No response_
### Node.js Version
20.15.0
### OS
Linux
### Language
Python
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Reproduce the failure with CDK CLI 2.166.0 using the Python example, focusing on ApplicationListener.from_lookup and AlbListenerTarget. Compare the accepted AlbTarget path with the failing listener path and inspect the generated Python/jsii types involved. Done means a listener returned by from_lookup can be passed to AlbListenerTarget without the type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100