0
votes

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?

2
Are you saying that you tried aws elbv2 --names my-load-balancer and queried for LoadBalancers[].DNSName and it didn't work?jarmod

2 Answers

1
votes
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
0
votes

aws elb describe-load-balancers --region | 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 with actual region.