aws-cdk-lib.aws_elasticloadbalancingv2.NetworkTargetGroup

class NetworkTargetGroup (construct)

LanguageType name
.NETAmazon.CDK.AWS.ElasticLoadBalancingV2.NetworkTargetGroup
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awselasticloadbalancingv2#NetworkTargetGroup
Javasoftware.amazon.awscdk.services.elasticloadbalancingv2.NetworkTargetGroup
Pythonaws_cdk.aws_elasticloadbalancingv2.NetworkTargetGroup
TypeScript (source)aws-cdk-lib » aws_elasticloadbalancingv2 » NetworkTargetGroup

Implements IConstruct, IDependable, ITargetGroup, INetworkTargetGroup

Define a Network Target Group.

Example

declare const listener: elbv2.NetworkListener;
declare const asg1: autoscaling.AutoScalingGroup;
declare const asg2: autoscaling.AutoScalingGroup;

const group = listener.addTargets('AppFleet', {
  port: 443,
  targets: [asg1],
});

group.addTarget(asg2);

Initializer

new NetworkTargetGroup(scope: Construct, id: string, props: NetworkTargetGroupProps)

Parameters

  • scope Construct
  • id string
  • props NetworkTargetGroupProps

Construct Props

NameTypeDescription
portnumberThe port on which the target receives traffic.
connectionTermination?booleanIndicates whether the load balancer terminates connections at the end of the deregistration timeout.
deregistrationDelay?DurationThe amount of time for Elastic Load Balancing to wait before deregistering a target.
healthCheck?HealthCheckHealth check configuration.
preserveClientIp?booleanIndicates whether client IP preservation is enabled.
protocol?ProtocolProtocol for target group, expects TCP, TLS, UDP, or TCP_UDP.
proxyProtocolV2?booleanIndicates whether Proxy Protocol version 2 is enabled.
targetGroupName?stringThe name of the target group.
targetType?TargetTypeThe type of targets registered to this TargetGroup, either IP or Instance.
targets?INetworkLoadBalancerTarget[]The targets to add to this target group.
vpc?IVpcThe virtual private cloud (VPC).

port

Type: number

The port on which the target receives traffic.


connectionTermination?

Type: boolean (optional, default: false)

Indicates whether the load balancer terminates connections at the end of the deregistration timeout.


deregistrationDelay?

Type: Duration (optional, default: 300)

The amount of time for Elastic Load Balancing to wait before deregistering a target.

The range is 0-3600 seconds.


healthCheck?

Type: HealthCheck (optional, default: The default value for each property in this configuration varies depending on the target.)

Health check configuration.

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html#aws-resource-elasticloadbalancingv2-targetgroup-properties


preserveClientIp?

Type: boolean (optional, default: false if the target group type is IP address and the target group protocol is TCP or TLS. Otherwise, true.)

Indicates whether client IP preservation is enabled.


protocol?

Type: Protocol (optional, default: TCP)

Protocol for target group, expects TCP, TLS, UDP, or TCP_UDP.


proxyProtocolV2?

Type: boolean (optional, default: false)

Indicates whether Proxy Protocol version 2 is enabled.


targetGroupName?

Type: string (optional, default: Automatically generated.)

The 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.


targetType?

Type: TargetType (optional, default: Determined automatically.)

The type of targets registered to this TargetGroup, either IP or Instance.

All targets registered into the group must be of this type. If you register targets to the TargetGroup in the CDK app, the TargetType is determined automatically.


targets?

Type: INetworkLoadBalancerTarget[] (optional, default: No targets.)

The targets to add to this target group.

Can be Instance, IPAddress, or any self-registering load balancing target. If you use either Instance or IPAddress as targets, all target must be of the same type.


vpc?

Type: IVpc (optional, default: undefined)

The virtual private cloud (VPC).

only if TargetType is Ip or InstanceId

Properties

NameTypeDescription
firstLoadBalancerFullNamestringFull name of first load balancer.
healthCheckHealthCheckHealth check for the members of this target group.
loadBalancerArnsstringA token representing a list of ARNs of the load balancers that route traffic to this target group.
loadBalancerAttachedIDependableList of constructs that need to be depended on to ensure the TargetGroup is associated to a load balancer.
metricsINetworkTargetGroupMetricsAll metrics available for this target group.
nodeNodeThe tree node.
targetGroupArnstringThe ARN of the target group.
targetGroupFullNamestringThe full name of the target group.
targetGroupLoadBalancerArnsstring[]ARNs of load balancers load balancing to this TargetGroup.
targetGroupNamestringThe name of the target group.

firstLoadBalancerFullName

Type: string

Full name of first load balancer.


healthCheck

Type: HealthCheck

Health check for the members of this target group.


loadBalancerArns

Type: string

A token representing a list of ARNs of the load balancers that route traffic to this target group.


loadBalancerAttached

Type: IDependable

List of constructs that need to be depended on to ensure the TargetGroup is associated to a load balancer.


metrics

Type: INetworkTargetGroupMetrics

All metrics available for this target group.


node

Type: Node

The tree node.


targetGroupArn

Type: string

The ARN of the target group.


targetGroupFullName

Type: string

The full name of the target group.


targetGroupLoadBalancerArns

Type: string[]

ARNs of load balancers load balancing to this TargetGroup.


targetGroupName

Type: string

The name of the target group.

Methods

NameDescription
addTarget(...targets)Add a load balancing target to this target group.
configureHealthCheck(healthCheck)Set/replace the target group's health check.
metricHealthyHostCount(props?)⚠️The number of targets that are considered healthy.
metricUnHealthyHostCount(props?)⚠️The number of targets that are considered unhealthy.
registerListener(listener)Register a listener that is load balancing to this target group.
setAttribute(key, value?)Set a non-standard attribute on the target group.
toString()Returns a string representation of this construct.
protected validateTargetGroup()
static fromTargetGroupAttributes(scope, id, attrs)Import an existing target group.

addTarget(...targets)

public addTarget(...targets: INetworkLoadBalancerTarget[]): void

Parameters

  • targets INetworkLoadBalancerTarget

Add a load balancing target to this target group.


configureHealthCheck(healthCheck)

public configureHealthCheck(healthCheck: HealthCheck): void

Parameters

  • healthCheck HealthCheck

Set/replace the target group's health check.


metricHealthyHostCount(props?)⚠️

public metricHealthyHostCount(props?: MetricOptions): Metric

⚠️ Deprecated: Use NetworkTargetGroup.metrics.healthyHostCount instead

Parameters

  • props MetricOptions

Returns

  • Metric

The number of targets that are considered healthy.


metricUnHealthyHostCount(props?)⚠️

public metricUnHealthyHostCount(props?: MetricOptions): Metric

⚠️ Deprecated: Use NetworkTargetGroup.metrics.healthyHostCount instead

Parameters

  • props MetricOptions

Returns

  • Metric

The number of targets that are considered unhealthy.


registerListener(listener)

public registerListener(listener: INetworkListener): void

Parameters

  • listener INetworkListener

Register a listener that is load balancing to this target group.

Don't call this directly. It will be called by listeners.


setAttribute(key, value?)

public setAttribute(key: string, value?: string): void

Parameters

  • key string
  • value string

Set a non-standard attribute on the target group.

See also: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#target-group-attributes


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


protected validateTargetGroup()

protected validateTargetGroup(): string[]

Returns

  • string[]

static fromTargetGroupAttributes(scope, id, attrs)

public static fromTargetGroupAttributes(scope: Construct, id: string, attrs: TargetGroupAttributes): INetworkTargetGroup

Parameters

  • scope Construct
  • id string
  • attrs TargetGroupAttributes

Returns

  • INetworkTargetGroup

Import an existing target group.