-
Notifications
You must be signed in to change notification settings - Fork 4k
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
elasticloadbalancingv2:Cannot construct AlbListenerTarget using lookUp #33220
Comments
reproducible in 2.177.0 from aws_cdk import (
Stack,
aws_ec2 as ec2,
aws_elasticloadbalancingv2 as elbv2,
aws_elasticloadbalancingv2_targets as elbv2_targets,
)
from constructs import Construct
import logging
class IssueTriagePyStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
# Get the default VPC
vpc = ec2.Vpc.from_lookup(self, "VPC", is_default=True)
# Create Application Load Balancer
alb = elbv2.ApplicationLoadBalancer(
self, "MyALB",
vpc=vpc,
internet_facing=True
)
# Create Target Group
target_group = elbv2.ApplicationTargetGroup(
self, "MyTargetGroup",
vpc=vpc,
port=80,
protocol=elbv2.ApplicationProtocol.HTTP,
target_type=elbv2.TargetType.INSTANCE
)
# Add Listener
listener = alb.add_listener(
"MyListener",
port=80,
default_target_groups=[target_group]
)
# add import statements below
alb = elbv2.ApplicationLoadBalancer.from_lookup(
self, 'ApplicationBalancer',
load_balancer_tags={'elasticbeanstalk:environment-name': 'myenv'}
)
logging.info(f'found alb with arn <{alb.load_balancer_arn}>')
elbv2_targets.AlbTarget(alb=alb, port=80)
listener = elbv2.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 = elbv2_targets.AlbListenerTarget(listener)
I'll check if this issue exists in TS later. |
OK I see the gap here. If we check the TS doc, AlbListenerTarget requires a Now, looking at CDK in python on AlbListenerTarget, it requires
but if you check the from_lookup method:
So I think you can't simply create an AlbListenerTarget() using an imported listener like that. |
Thanks for checking, pahud. |
Describe the bug
Constructing AlbListenerTarget with Listener fromLookup fails:
==>
Regression Issue
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 ofAlbTarget
.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
The text was updated successfully, but these errors were encountered: