Skip to main content

target_groups

Creates, updates, deletes, gets or lists a target_groups resource.

Overview

Nametarget_groups
TypeResource
Idaws.elbv2.target_groups

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
health_check_enabledbooleanIndicates whether health checks are enabled.
health_check_interval_secondsintegerThe approximate amount of time, in seconds, between health checks of an individual target.
health_check_pathstringThe destination for health checks on the targets.
health_check_portstringThe port to use to connect with the target.
health_check_protocolstringThe protocol to use to connect with the target. The GENEVE, TLS, UDP, and TCP_UDP protocols are not supported for health checks.
health_check_timeout_secondsintegerThe amount of time, in seconds, during which no response means a failed health check.
healthy_threshold_countintegerThe number of consecutive health checks successes required before considering an unhealthy target healthy.
ip_address_typestringThe IP address type. The default value is ipv4.
load_balancer_arnsstringThe Amazon Resource Name (ARN) of the load balancer that routes traffic to this target group. You can use each target group with only one load balancer.
matcherstringThe HTTP or gRPC codes to use when checking for a successful response from a target.
portintegerThe port on which the targets are listening. This parameter is not used if the target is a Lambda function.
protocolstringThe protocol to use for routing traffic to the targets.
protocol_versionstring[HTTP/HTTPS protocol] The protocol version. The possible values are GRPC, HTTP1, and HTTP2.
target_control_portintegerThe port on which the target control agent and application load balancer exchange management traffic for the target optimizer feature.
target_group_arnstringThe Amazon Resource Name (ARN) of the target group.
target_group_namestringThe name of the target group.
target_typestringThe type of target that you must specify when registering targets with this target group. The possible values are instance (register targets by instance ID), ip (register targets by IP address), lambda (register a single Lambda function as a target), or alb (register a single Application Load Balancer as a target).
unhealthy_threshold_countintegerThe number of consecutive health check failures required before considering the target unhealthy.
vpc_idstringThe ID of the VPC for the targets.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_target_groupsselectregionLoadBalancerArn, TargetGroupArns, Names, Marker, PageSizeDescribes the specified target groups or all of your target groups. By default, all target groups are described. Alternatively, you can specify one of the following to filter the results: the ARN of the load balancer, the names of one or more target groups, or the ARNs of one or more target groups.
register_targetsinsertTargetGroupArn, Targets, regionRegisters the specified targets with the specified target group. If the target is an EC2 instance, it must be in the running state when you register it. By default, the load balancer routes requests to registered targets using the protocol and port for the target group. Alternatively, you can override the port for a target when you register it. You can register each EC2 instance or IP address with the same target group multiple times using different ports. For more information, see the following: Register targets for your Application Load Balancer Register targets for your Network Load Balancer Register targets for your Gateway Load Balancer
create_target_groupinsertregionName, Protocol, ProtocolVersion, Port, VpcId, HealthCheckProtocol, HealthCheckPort, HealthCheckEnabled, HealthCheckPath, HealthCheckIntervalSeconds, HealthCheckTimeoutSeconds, HealthyThresholdCount, UnhealthyThresholdCount, Matcher, TargetType, Tags, IpAddressType, TargetControlPortCreates a target group. For more information, see the following: Target groups for your Application Load Balancers Target groups for your Network Load Balancers Target groups for your Gateway Load Balancers This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple target groups with the same settings, each call succeeds.
modify_target_groupupdateTargetGroupArn, regionHealthCheckProtocol, HealthCheckPort, HealthCheckPath, HealthCheckEnabled, HealthCheckIntervalSeconds, HealthCheckTimeoutSeconds, HealthyThresholdCount, UnhealthyThresholdCount, MatcherModifies the health checks used when evaluating the health state of the targets in the specified target group.
deregister_targetsdeleteTargetGroupArn, Targets, regionDeregisters the specified targets from the specified target group. After the targets are deregistered, they no longer receive traffic from the load balancer. The load balancer stops sending requests to targets that are deregistering, but uses connection draining to ensure that in-flight traffic completes on the existing connections. This deregistration delay is configured by default but can be updated for each target group. For more information, see the following: Deregistration delay in the Application Load Balancers User Guide Deregistration delay in the Network Load Balancers User Guide Deregistration delay in the Gateway Load Balancers User Guide Note: If the specified target does not exist, the action returns successfully.
delete_target_groupdeleteTargetGroupArn, regionDeletes the specified target group. You can delete a target group if it is not referenced by any actions. Deleting a target group also deletes any associated health checks. Deleting a target group does not affect its registered targets. For example, any EC2 instances continue to run until you stop or terminate them.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
TargetGroupArnstringThe Amazon Resource Name (ARN) of the target group.
TargetsarrayThe targets. If you specified a port override when you registered a target, you must specify both the target ID and the port when you deregister it.
regionstringAWS region (default: us-east-1)
HealthCheckEnabledbooleanIndicates whether health checks are enabled. If the target type is lambda, health checks are disabled by default but can be enabled. If the target type is instance, ip, or alb, health checks are always enabled and can't be disabled.
HealthCheckIntervalSecondsintegerThe approximate amount of time, in seconds, between health checks of an individual target.
HealthCheckPathstring[HTTP/HTTPS health checks] The destination for health checks on the targets. [HTTP1 or HTTP2 protocol version] The ping path. The default is /. [GRPC protocol version] The path of a custom health check method with the format /package.service/method. The default is /Amazon Web Services.ALB/healthcheck.
HealthCheckPortstringThe port the load balancer uses when performing health checks on targets.
HealthCheckProtocolstringThe protocol the load balancer uses when performing health checks on targets. For Application Load Balancers, the default is HTTP. For Network Load Balancers and Gateway Load Balancers, the default is TCP. The TCP protocol is not supported for health checks if the protocol of the target group is HTTP or HTTPS. It is supported for health checks only if the protocol of the target group is TCP, TLS, UDP, or TCP_UDP. The GENEVE, TLS, UDP, TCP_UDP, QUIC, and TCP_QUIC protocols are not supported for health checks.
HealthCheckTimeoutSecondsinteger[HTTP/HTTPS health checks] The amount of time, in seconds, during which no response means a failed health check.
HealthyThresholdCountintegerThe number of consecutive health checks successes required before considering an unhealthy target healthy.
IpAddressTypestringThe IP address type. The default value is ipv4.
LoadBalancerArnstringThe Amazon Resource Name (ARN) of the load balancer.
MarkerstringThe marker for the next set of results. (You received this marker from a previous call.)
Matcherobject[HTTP/HTTPS health checks] The HTTP or gRPC codes to use when checking for a successful response from a target. For target groups with a protocol of TCP, TCP_UDP, UDP or TLS the range is 200-599. For target groups with a protocol of HTTP or HTTPS, the range is 200-499. For target groups with a protocol of GENEVE, the range is 200-399.
NamestringThe name of the target group. This name must be unique per region per account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen.
NamesarrayThe names of the target groups.
PageSizeintegerThe maximum number of results to return with this call.
PortintegerThe port on which the targets receive traffic. This port is used unless you specify a port override when registering the target. If the target is a Lambda function, this parameter does not apply. If the protocol is GENEVE, the supported port is 6081.
ProtocolstringThe protocol to use for routing traffic to the targets. For Application Load Balancers, the supported protocols are HTTP and HTTPS. For Network Load Balancers, the supported protocols are TCP, TLS, UDP, TCP_UDP, QUIC, or TCP_QUIC. For Gateway Load Balancers, the supported protocol is GENEVE. A TCP_UDP listener must be associated with a TCP_UDP target group. A TCP_QUIC listener must be associated with a TCP_QUIC target group. If the target is a Lambda function, this parameter does not apply.
ProtocolVersionstring[HTTP/HTTPS protocol] The protocol version. Specify GRPC to send requests to targets using gRPC. Specify HTTP2 to send requests to targets using HTTP/2. The default is HTTP1, which sends requests to targets using HTTP/1.1.
TagsarrayThe tags to assign to the target group.
TargetControlPortintegerThe port on which the target control agent and application load balancer exchange management traffic for the target optimizer feature.
TargetGroupArnsarrayThe Amazon Resource Names (ARN) of the target groups.
TargetTypestringThe type of target that you must specify when registering targets with this target group. You can't specify targets for a target group using more than one target type. instance - Register targets by instance ID. This is the default value. ip - Register targets by IP address. You can specify IP addresses from the subnets of the virtual private cloud (VPC) for the target group, the RFC 1918 range (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16), and the RFC 6598 range (100.64.0.0/10). You can't specify publicly routable IP addresses. lambda - Register a single Lambda function as a target. alb - Register a single Application Load Balancer as a target.
UnhealthyThresholdCountintegerThe number of consecutive health check failures required before considering the target unhealthy.
VpcIdstringThe identifier of the virtual private cloud (VPC). If the target is a Lambda function, this parameter does not apply. Otherwise, this parameter is required.

SELECT examples

Describes the specified target groups or all of your target groups. By default, all target groups are described. Alternatively, you can specify one of the following to filter the results: the ARN of the load balancer, the names of one or more target groups, or the ARNs of one or more target groups.

SELECT
health_check_enabled,
health_check_interval_seconds,
health_check_path,
health_check_port,
health_check_protocol,
health_check_timeout_seconds,
healthy_threshold_count,
ip_address_type,
load_balancer_arns,
matcher,
port,
protocol,
protocol_version,
target_control_port,
target_group_arn,
target_group_name,
target_type,
unhealthy_threshold_count,
vpc_id
FROM aws.elbv2.target_groups
WHERE region = '{{ region }}' -- required
AND LoadBalancerArn = '{{ LoadBalancerArn }}'
AND TargetGroupArns = '{{ TargetGroupArns }}'
AND Names = '{{ Names }}'
AND Marker = '{{ Marker }}'
AND PageSize = '{{ PageSize }}'
;

INSERT examples

Registers the specified targets with the specified target group. If the target is an EC2 instance, it must be in the running state when you register it. By default, the load balancer routes requests to registered targets using the protocol and port for the target group. Alternatively, you can override the port for a target when you register it. You can register each EC2 instance or IP address with the same target group multiple times using different ports. For more information, see the following: Register targets for your Application Load Balancer Register targets for your Network Load Balancer Register targets for your Gateway Load Balancer

INSERT INTO aws.elbv2.target_groups (
TargetGroupArn,
Targets,
region
)
SELECT
'{{ TargetGroupArn }}',
'{{ Targets }}',
'{{ region }}'
RETURNING
line_items
;

UPDATE examples

Modifies the health checks used when evaluating the health state of the targets in the specified target group.

UPDATE aws.elbv2.target_groups
SET
-- No updatable properties
WHERE
TargetGroupArn = '{{ TargetGroupArn }}' --required
AND region = '{{ region }}' --required
AND HealthCheckProtocol = '{{ HealthCheckProtocol}}'
AND HealthCheckPort = '{{ HealthCheckPort}}'
AND HealthCheckPath = '{{ HealthCheckPath}}'
AND HealthCheckEnabled = {{ HealthCheckEnabled}}
AND HealthCheckIntervalSeconds = '{{ HealthCheckIntervalSeconds}}'
AND HealthCheckTimeoutSeconds = '{{ HealthCheckTimeoutSeconds}}'
AND HealthyThresholdCount = '{{ HealthyThresholdCount}}'
AND UnhealthyThresholdCount = '{{ UnhealthyThresholdCount}}'
AND Matcher = '{{ Matcher}}'
RETURNING
line_items;

DELETE examples

Deregisters the specified targets from the specified target group. After the targets are deregistered, they no longer receive traffic from the load balancer. The load balancer stops sending requests to targets that are deregistering, but uses connection draining to ensure that in-flight traffic completes on the existing connections. This deregistration delay is configured by default but can be updated for each target group. For more information, see the following: Deregistration delay in the Application Load Balancers User Guide Deregistration delay in the Network Load Balancers User Guide Deregistration delay in the Gateway Load Balancers User Guide Note: If the specified target does not exist, the action returns successfully.

DELETE FROM aws.elbv2.target_groups
WHERE TargetGroupArn = '{{ TargetGroupArn }}' --required
AND Targets = '{{ Targets }}' --required
AND region = '{{ region }}' --required
;