Find AWS NLB IP with CLI

From Luniwiki
Jump to: navigation, search

Find IP NLB by command line

Replace NLBBalancer with the name of the NLB

aws ec2 describe-network-interfaces --filters Name=description,Values="ELB $(aws elbv2 describe-load-balancers --names NLBBalancer --profile ${PROFILE} | jq .LoadBalancers[0].LoadBalancerArn | cut -d '/' -f 2- | rev | cut -c 2- | rev)" --query 'NetworkInterfaces[*].PrivateIpAddresses[*].PrivateIpAddress' --output text --profile ${PROFILE}

Example

# aws ec2 describe-network-interfaces --filters Name=description,Values="ELB $(aws elbv2 describe-load-balancers --names MyNLB --profile ${PROFILE} | jq .LoadBalancers[0].LoadBalancerArn | cut -d '/' -f 2- | rev | cut -c 2- | rev)" --query 'NetworkInterfaces[*].PrivateIpAddresses[*].PrivateIpAddress' --output text --profile ${PROFILE}
10.123.94.120
10.123.19.79
10.123.138.9

References

Daniel Simao 18:30, 5 January 2023 (EST)