Filter LoadBalancer By VPC ID

孤街浪徒 提交于 2019-12-10 20:58:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!