# NetworkTargetGroup

Define a Network Target Group.

Extends: Construct › TargetGroupBase › NetworkTargetGroup
Implements: INetworkTargetGroup, INetworkTargetGroupRef, ITargetGroup, IEnvironmentAware, ITargetGroupRef, IConstruct, IDependable

- Source: [`aws-elasticloadbalancingv2/lib/nlb/network-target-group.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/nlb/network-target-group.ts#L137)
- Type last changed: v2.234.0 · 8 Jan 2026

## Example

```ts
import * as elb from 'aws-cdk-lib/aws-elasticloadbalancing';
import * as elb2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';

declare const clb: elb.LoadBalancer;
declare const alb: elb2.ApplicationLoadBalancer;
declare const nlb: elb2.NetworkLoadBalancer;

const albListener = alb.addListener('ALBListener', { port: 80 });
const albTargetGroup = albListener.addTargets('ALBFleet', { port: 80 });

const nlbListener = nlb.addListener('NLBListener', { port: 80 });
const nlbTargetGroup = nlbListener.addTargets('NLBFleet', { port: 80 });

const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGroup', {
  loadBalancers: [
    codedeploy.LoadBalancer.classic(clb),
    codedeploy.LoadBalancer.application(albTargetGroup),
    codedeploy.LoadBalancer.network(nlbTargetGroup),
  ]
});
```

## Initializer

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

## Construct Props

- `connectionTermination`: boolean = false — Indicates whether the load balancer terminates connections at the end of the deregistration timeout.

- `crossZoneEnabled`: boolean — Indicates whether cross zone load balancing is enabled.

  **Default:** use load balancer configuration

- `deregistrationDelay`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = 300 — The amount of time for Elastic Load Balancing to wait before deregistering a target.

  The range is 0-3600 seconds.

- `healthCheck`: [HealthCheck](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.HealthCheck.html) — Health check configuration.

  **Default:** The default value for each property in this configuration varies depending on the target.

- `ipAddressType`: [TargetGroupIpAddressType](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.TargetGroupIpAddressType.html) — The type of IP addresses of the targets registered with the target group.

  **Default:** undefined - ELB defaults to IPv4

- `port`: number (required) — The port on which the target receives traffic.

- `preserveClientIp`: boolean — Indicates whether client IP preservation is enabled.

  **Default:** false if the target group type is IP address and the target group protocol is TCP or TLS. Otherwise, true.

- `protocol`: [Protocol](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.Protocol.html) = TCP — Protocol for target group, expects TCP, TLS, UDP, or TCP_UDP.

- `proxyProtocolV2`: boolean = false — Indicates whether Proxy Protocol version 2 is enabled.

- `targetGroupHealth`: [TargetGroupHealth](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.TargetGroupHealth.html) — Configuring target group health.

  **Default:** use default configuration

- `targetGroupName`: string — The name of the target group.

  **Default:** Automatically generated.

  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.

- `targets`: [INetworkLoadBalancerTarget](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.INetworkLoadBalancerTarget.html)[] — The targets to add to this target group.

  **Default:** No targets.

  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.

- `targetType`: [TargetType](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.TargetType.html) — The type of targets registered to this TargetGroup, either IP or Instance.

  **Default:** Determined automatically.

  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.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) = undefined — The virtual private cloud (VPC).

  only if `TargetType` is `Ip` or `InstanceId`

## Properties

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

- `firstLoadBalancerFullName`: string — Full name of first load balancer.

- `healthCheck`: [HealthCheck](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.HealthCheck.html) — Health check for the members of this target group.

- `isNetworkTargetGroup`: boolean — Indicates that this is a Network Target Group.

  Will always return true, but is necessary to prevent accidental structural
  equality in TypeScript.

- `loadBalancerArns`: string — A token representing a list of ARNs of the load balancers that route traffic to this target group.

- `loadBalancerAttached`: [IDependable](/cdk/api/v2/docs/constructs.IDependable.html) — List of constructs that need to be depended on to ensure the TargetGroup is associated to a load balancer.

- `metrics`: [INetworkTargetGroupMetrics](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.INetworkTargetGroupMetrics.html) — All metrics available for this target group.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `targetGroupArn`: string — The ARN of the target group.

- `targetGroupFullName`: string — The full name of the target group.

- `targetGroupLoadBalancerArns`: string[] — ARNs of load balancers load balancing to this TargetGroup.

- `targetGroupName`: string — The name of the target group.

- `targetGroupRef`: [TargetGroupReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_elasticloadbalancingv2.TargetGroupReference.html) — A reference to this target group.

## Methods

- `addTarget(...targets: INetworkLoadBalancerTarget[]): void` — Add a load balancing target to this target group.

- `configureHealthCheck(healthCheck: HealthCheck): void` — Set/replace the target group's health check.

- `fromTargetGroupAttributes(scope: Construct, id: string, attrs: TargetGroupAttributes): INetworkTargetGroup` (static) — Import an existing target group.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `metricHealthyHostCount(props?: MetricOptions): Metric` — Use ``NetworkTargetGroup.metrics.healthyHostCount`` instead

- `metricUnHealthyHostCount(props?: MetricOptions): Metric` — Use ``NetworkTargetGroup.metrics.healthyHostCount`` instead

- `registerListener(listener: INetworkListenerRef): void` — Register a listener that is load balancing to this target group.

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

- `setAttribute(key: string, value?: string): void` — Set a non-standard attribute on the target group.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
