如何通过CLI获取AWS目标组中已注册目标的列表 [英] how to get list of registered targets in AWS target group via CLI
问题描述
我们正在尝试获取目标组中已注册目标(实例)的状态.可以使用命令 aws elbv2 describe-target-health --target-group-arn $ {TG} --targets Id = $ {ID},Port = $ {PORT}
,参考.我们可以通过 aws ecs describe-tasks --cluster $ CLUSTER --tasks $ task
命令,
We are trying to get the state of a registered target (instance) in a target group. This can be done with the command aws elbv2 describe-target-health --target-group-arn ${TG} --targets Id=${ID},Port=${PORT}
, reference. We are able to get the PORT via the aws ecs describe-tasks --cluster $CLUSTER --tasks $task
command, reference. But how can the target's instance Id be retrieved via CLI?
推荐答案
这将为您提供目标组中已注册实例ID的数组.当拥有目标ARN时,为什么要使用目标ID?所以我跳过目标ID,仅使用目标ARN.
This will give you the array of registered instance ID in a target group. When you have target ARN why you using target ID? so I am skipping target ID and using just target ARN.
aws elbv2 describe-target-health --target-group-arn ${TG} --query 'TargetHealthDescriptions[*].Target.Id'
这篇关于如何通过CLI获取AWS目标组中已注册目标的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!