I have two loadbalancers associated with two different VPC.
I am able to list all loadbalancers using AWS CLI.
Now I need to retrieve the name of the loadbalancer in a particular VPC. Is it can be done via AWS CLI ??
It is true that the ELB service provides no service side filtering of results. However, you don't need to write a script to get what you want. You can use the built-in jmespath querying capability of AWSCLI.
$ aws elb describe-load-balancers --query 'LoadBalancerDescriptions[?VPCId==`vpc-12345678`]|[].LoadBalancerName'
[
"elb1",
"elb2"
]
$
Should return only a list of names of load balancers that are in vpc-12345678
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With