Search code examples
amazon-web-servicesaws-lambdaaws-sdkamazon-elbnetwork-interface

AWS - Affect Load Balancer's tags to its Network Interfaces (ENI)


when I create a Classic Load Balancer (CLB) or an Application Load Balancer (ALB), an Elastic Network Interface (ENI) is automatically created and attached to the Load Balancer.

My goal: I would like to affect tags from my load balancer to its network interface.

It's a bit weird, because the:

  • com.amazonaws.services.ec2.model.Instance has a getNetworkInterfaces() for listing EC2 instance network interfaces.
  • com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription does not have a method for listing CLB's network interfaces.
  • com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancer does not have a method for listing ALB's network interfaces.

I found an alternative solution but I am not satisfied with it:

  1. I list all the Network Interfaces from EC2 com.amazonaws.services.ec2.AmazonEC2#describeNetworkInterfaces()
  2. I get the Network Interface's description field. This description field contains the Load Balancer's name. If it's a CLB the format is ELB classic-load-balancer-name, if it's an ALB the format is ELB app/application-load-balancer-name/f8bb2c1b66c9a086
  3. I link the parsed description with the Load Balancer.

If someone change the description field, this solution doesn't work anymore, what is the best way to affect a Load Balancer's tags to its Network Interface?

Note: I am using the Java AWS-SDK.


Solution

  • Elastic Network Interface (ENI) is automatically created and attached to the Load Balancer.

    More precisely, at least one ENI is created and attached to the balancer in each availability zone where the balancer is deployed (except NLB, which should only have one per AZ). Over the life of the balancer, new ENIs will appear and old ones will disappear, as the balancer scales horizontally (number of nodes) and/or vertically (capacity of underlying hardware), all of which is handled transparently by the infrastructure. Even though you can tag them, the tagging will become stale over time.

    If someone change the description field

    You can't edit the description in these ENIs. Access is denied.