Bootstrap FreeKB - Amazon Web Services (AWS) - List Target Groups using the AWS CLI
Amazon Web Services (AWS) - List Target Groups using the AWS CLI


If you are not familiar with AWS Application Load Balancers, check out my article FreeKB - Amazon Web Services (AWS) - Getting Started with Application Load Balancer (ALB).

This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI

Let's say you have two or more EC2 instances that are producing web apps. An application load balancer can be used to load balance the requests for the web app.

 

A Target Group contains:

  • One or more EC2 instances using the EC2 instances ID
  • One or more EC2 instances via IP address
  • One or more EC2 instances via Lambda
  • One or more Application Load Balancers (in other words, a group of Application Load Balancers)

 

The aws elbv2 describe-target-groups command can be used to list your Target Groups.

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/af5707bbd67c69ab",
            "TargetGroupName": "my-target-group",
            "Protocol": "HTTP",
            "Port": 80,
            "VpcId": "vpc-123abd654dsf356s1",
            "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 Buy Me A Coffee



Comments


Add a Comment


Please enter 64fff8 in the box below so that we can be sure you are a human.