aws_cdk.aws_elasticloadbalancingv2: object has no attribute 'metric' #13848
Labels
@aws-cdk/aws-elasticloadbalancingv2
Related to Amazon Elastic Load Balancing V2
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
Description
When i lookup an existing Application Load Balancer using the ARN, I can't seem to access metrics associated with it through the metric*(s) methods. I also get a default ARN returned for the object.
Reproduction Steps
alb = elbv2.ApplicationLoadBalancer.from_lookup(self, "ALB", load_balancer_arn=arn) ## arn:aws:elasticloadbalancing:us-east-1:<AccNo>:loadbalancer/app/lb-test/<Id> metric = alb.metric(elbv2.HttpCodeElb.ELB_4XX_COUNT) print(metric)
What did you expect to happen?
To get the metric object back so that I can create a Cloudwatch Alarm based off of this.
What actually happened?
I get an error saying that the object has no attribute metric :
Traceback (most recent call last): File "app.py", line 13, in <module> ALBStack(app, "ALBStack", env=deploy_env) File "/Users/mclean/code/alerts-poc/.venv/lib/python3.8/site-packages/jsii/_runtime.py", line 83, in __call__ inst = super().__call__(*args, **kwargs) File "/Users/mclean/code/alerts-poc/stacks/alb.py", line 22, in __init__ metric = alb.metric(elbv2.HttpCodeElb.ELB_4XX_COUNT) File "/Users/mclean/code/alerts-poc/.venv/lib/python3.8/site-packages/jsii/_reference_map.py", line 149, in __getattr__ raise AttributeError(f"'%s' object has no attribute '%s'" % (type_info, name)) AttributeError: '<class 'aws_cdk.core.Resource'>+<class 'aws_cdk.aws_elasticloadbalancingv2._IApplicationLoadBalancerProxy'>' object has no attribute 'metric'
Also if I do :
print(alb.load_balancer_arn)
I get back :
arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/application/my-load-balancer/50dc6c495c0c9188
which looks completely wrong and looks to be some kind of default value.
Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: