Amazon Web Services (AWS) - List Target Groups using the AWS CLI
                
            
            
            
            
            
            
                           
                
            
            
            
                
    
    
    
            
                
                    by
                    Jeremy Canfield  |  
                    Updated: August 02 2023
                    
                          |  Amazon Web Services (AWS) articles
                    
                    
                    
                
            
            An Elastic Load Balancer (ELB) is typically used to load balance requests across two (or more) different EC2 instances.

This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
The aws elbv2 describe-target-groups command can be used to list the Target Groups that have been created.
aws elbv2 describe-target-groups
And here is an example of how to limit the output using the --query option.
aws elbv2 describe-target-groups --query 'TargetGroups[?TargetGroupName==`my-target-group`]'
Something like this should be returned.
{
    "TargetGroups": [
        {
            "TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/my-target-group/b12348d3a5abcd1d",
            "TargetGroupName": "my-target-group",
            "Protocol": "HTTP",
            "Port": 80,
            "VpcId": "vpc-0141234fa33abcd01",
            "HealthCheckProtocol": "HTTP",
            "HealthCheckPort": "traffic-port",
            "HealthCheckEnabled": true,
            "HealthCheckIntervalSeconds": 30,
            "HealthCheckTimeoutSeconds": 5,
            "HealthyThresholdCount": 5,
            "UnhealthyThresholdCount": 2,
            "HealthCheckPath": "/",
            "Matcher": {
                "HttpCode": "200"
            },
            "LoadBalancerArns": [],
            "TargetType": "instance",
            "ProtocolVersion": "HTTP1",
            "IpAddressType": "ipv4"
        }
    ]
}
Did you find this article helpful?
If so, consider buying me a coffee over at 