本文介绍了通过VPC ID过滤LoadBalancer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个与两个不同的VPC相关联的负载均衡器.
I have two loadbalancers associated with two different VPC.
我能够使用AWS CLI列出所有负载均衡器.
I am able to list all loadbalancers using AWS CLI.
现在,我需要在特定VPC中检索负载均衡器的名称.可以通过AWS CLI完成吗?
Now I need to retrieve the name of the loadbalancer in a particular VPC. Is it can be done via AWS CLI ??
推荐答案
确实,ELB服务没有提供服务方对结果的过滤.但是,您无需编写脚本即可获得所需的内容.您可以使用AWSCLI的内置jmespath查询功能.
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"
]
$
应仅返回vpc-12345678
中的负载均衡器名称列表.
Should return only a list of names of load balancers that are in vpc-12345678
.
这篇关于通过VPC ID过滤LoadBalancer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!