Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use ModifyTargetGroup with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use ModifyTargetGroup with a CLI

The following code examples show how to use ModifyTargetGroup.

CLI
AWS CLI

To modify the health check configuration for a target group

The following modify-target-group example changes the configuration of the health checks used to evaluate the health of the targets for the specified target group. Note that due to the way the CLI parses commas, you must surround the range for the --matcher option with single quotes instead of double quotes.

aws elbv2 modify-target-group \ --target-group-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f \ --health-check-protocol HTTPS \ --health-check-port 443 \ --matcher HttpCode='200,299'

Output:

{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f", "TargetGroupName": "my-https-targets", "Protocol": "HTTPS", "Port": 443, "VpcId": "vpc-3ac0fb5f", "HealthCheckProtocol": "HTTPS", "HealthCheckPort": "443", "HealthCheckEnabled": true, "HealthCheckIntervalSeconds": 30, "HealthCheckTimeoutSeconds": 5, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "Matcher": { "HttpCode": "200,299" }, "LoadBalancerArns": [ "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188" ], "TargetType": "instance", "ProtocolVersion": "HTTP1", "IpAddressType": "ipv4" } ] }

For more information, see Target groups in the Applicaion Load Balancers Guide.

PowerShell
Tools for PowerShell

Example 1: This example modifes the properties of the specified Target Group.

Edit-ELB2TargetGroup -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970' -HealthCheckIntervalSecond 60 -HealthCheckPath '/index.html' -HealthCheckPort 8080

Output:

HealthCheckEnabled : True HealthCheckIntervalSeconds : 60 HealthCheckPath : /index.html HealthCheckPort : 8080 HealthCheckProtocol : HTTP HealthCheckTimeoutSeconds : 5 HealthyThresholdCount : 5 LoadBalancerArns : {} Matcher : Amazon.ElasticLoadBalancingV2.Model.Matcher Port : 80 Protocol : HTTP TargetGroupArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970 TargetGroupName : test-tg TargetType : instance UnhealthyThresholdCount : 2 VpcId : vpc-2cfd7000
  • For API details, see ModifyTargetGroup in AWS Tools for PowerShell Cmdlet Reference.

AWS CLI

To modify the health check configuration for a target group

The following modify-target-group example changes the configuration of the health checks used to evaluate the health of the targets for the specified target group. Note that due to the way the CLI parses commas, you must surround the range for the --matcher option with single quotes instead of double quotes.

aws elbv2 modify-target-group \ --target-group-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f \ --health-check-protocol HTTPS \ --health-check-port 443 \ --matcher HttpCode='200,299'

Output:

{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f", "TargetGroupName": "my-https-targets", "Protocol": "HTTPS", "Port": 443, "VpcId": "vpc-3ac0fb5f", "HealthCheckProtocol": "HTTPS", "HealthCheckPort": "443", "HealthCheckEnabled": true, "HealthCheckIntervalSeconds": 30, "HealthCheckTimeoutSeconds": 5, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "Matcher": { "HttpCode": "200,299" }, "LoadBalancerArns": [ "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188" ], "TargetType": "instance", "ProtocolVersion": "HTTP1", "IpAddressType": "ipv4" } ] }

For more information, see Target groups in the Applicaion Load Balancers Guide.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.