LeonanCarvalho
LeonanCarvalho

Reputation: 1869

How to describe loadbalances on aws cli elbv2 by name?

I'm using the AWS CLI to retrieve the load balancer IP to another EC where runs a service that needs the IP and Port(TCP) in a configuration file.

Recently we migrated from classic load balancer to network load balancer.

Using classic load balancer the name was possible to retrieve it using the following command:

aws elb describe-load-balancers \
                --load-balancer-name my-load-balancer \
                --query LoadBalancerDescriptions[].DNSName \
                --output text

But I didn't find any way to do the same using the elbv2. How can I get the DNSName from it based on load balancer Name?

Upvotes: 0

Views: 2869

Answers (2)

Paul
Paul

Reputation: 29

aws elb describe-load-balancers --region <REGIONNAME> | jq .LoadBalancerDescriptions[]."LoadBalancerName" | tr -d '"'

This command can filter based on the Load Balancer Name. Also, "tr" command is used to filter out the double quotes from the beginning and end of the Load Balancer names. Replace <REGIONNAME> with the actual region.

Upvotes: 3

Sajeer Noohukannu
Sajeer Noohukannu

Reputation: 678

aws elbv2 describe-load-balancers \
                --names my-load-balancer \
                --query LoadBalancers[].DNSName \
                --output text

Use this.

Type below command in terminal to know all kind of options

aws elbv2 describe-load-balancers help

Upvotes: 3

Related Questions