cdklabs / cdk-monitoring-constructs

Easy-to-use CDK constructs for monitoring your AWS infrastructure
https://constructs.dev/packages/cdk-monitoring-constructs
Apache License 2.0
443 stars 56 forks source link

Cannot use NetworkLoadBalancer.fromNetworkLoadBalancerAttributes with .monitorFargateNetworkLoadBalancer #476

Closed btd closed 5 months ago

btd commented 5 months ago

Version

"7.2.2"

Steps and/or minimal code example to reproduce

  1. Init Facade
  2. call monitoring.monitorFargateNetworkLoadBalancer({ networkLoadBalancer: NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(...) })

You will get Invalid type of load balancer or target group (only ALB and NLB are supported).

This is happening that internally code is too much shared with ALB and it tries to get type from name of constructor function/class, which in case of imported NLB will not contain Network in name.

Expected behavior

It should work with imported NLB/ALB

Actual behavior

Throwing error Invalid type of load balancer or target group (only ALB and NLB are supported).

Other details

In each function you ask for specific type of ALB/NLB via separate properties networkLoadBalancer and applicationLoadBalancer - so you can keep this information internally