1

We are running low on IP addresses in a specific subnet in AWS. I was able to find all ec2 instances using IP address from this specific subnet. Now I am trying to find all Elastic Load Balancers using this subnet via the AWS CLI.

I know that I can run the following to find all ELB on a specific VPC:

aws elb describe-load-balancers --query 'LoadBalancerDescriptions[?VPCId==vpc-12345678]|[].LoadBalancerName'

I think the issue with subnets is you can have multiple subnets. So it is a list instead of just one value like VPCId.

I tried the following:

aws --region us-east-1 elb describe-load-balancers --query 'LoadBalancerDescriptions[?Subnets==subnet-1234546]|[].LoadBalancerName'

But it came back with nothing even though I can see from previous search that some ELB do have the specific subnet I am looking for. I think it is due to it being a list of subnets but I'm unsure how how to search for it.

Any ideas?

Thank you.

Wolverine313
  • 301
  • 2
  • 8

1 Answers1

4

Will this work for you?

aws elb describe-load-balancers --query 'LoadBalancerDescriptions[?contains(Subnets, `subnet-1234546`)==`true`].LoadBalancerName' --output text
krishna_mee2004
  • 6,556
  • 2
  • 35
  • 45