问题
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 ??
回答1:
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
.
来源:https://stackoverflow.com/questions/32392303/filter-loadbalancer-by-vpc-id