如何使用AWS CLI命令仅获取负载均衡器443监听器的ID与ARN
获取负载均衡器443端口监听器的ID和ARN(AWS CLI)
你可以通过AWS CLI的describe-listeners命令,结合筛选条件和查询参数,精准提取监听443端口的监听器ID与ARN:
应用负载均衡(ALB/NLB/GLB)
使用elbv2命令集(适用于现代负载均衡器):
aws elbv2 describe-listeners --load-balancer-arn <你的负载均衡器ARN> --query 'Listeners[?Port==`443`].[ListenerArn, ListenerId]' --output table
参数说明:
<你的负载均衡器ARN>:替换为目标负载均衡器的ARN,若不知道可通过aws elbv2 describe-load-balancers命令查询。--query:利用JMESPath语法筛选端口为443的监听器,仅保留ListenerArn和ListenerId字段。--output table:以表格格式输出结果,若需要JSON格式可替换为--output json或直接省略该参数。
经典负载均衡(CLB)
若使用的是经典负载均衡,需使用elb命令集:
aws elb describe-listeners --load-balancer-name <你的负载均衡器名称> --query 'ListenerDescriptions[?Listener.Port==`443`].[Listener.ListenerArn, Listener.ListenerId]' --output table
内容的提问来源于stack exchange,提问作者Ganesh AWS
相关产品推荐
相关产品推荐

