How to get list of instances attached to ELB in form of comma separated list

瘦欲@ 提交于 2021-02-10 06:58:17

问题


I want to get list of all instances attached to an ELB (need to use them in further processing).

Here is what I have done so far :

aws elb describe-load-balancers --load-balancer-name 'my-elb' --output json --query "LoadBalancerDescriptions[*].Instances[*].InstanceId"

However, above command gives me the list in JSON format.

[
    [
        "i-05676776d8cd4ab5344b0d",
"i-05676776"
    ]
]

How can I do?

Thanks!


回答1:


--output text and pipe it to paste

aws elb describe-load-balancers --load-balancer-name 'my-elb' --output text --query "LoadBalancerDescriptions[*].Instances[*].InstanceId" | paste -d, -s


来源:https://stackoverflow.com/questions/42706884/how-to-get-list-of-instances-attached-to-elb-in-form-of-comma-separated-list

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