# AddApplicationTargetsProps

Properties for adding new targets to a listener.

Extends: AddApplicationTargetsProps
Extends: AddRuleProps

- Source: [`aws-elasticloadbalancingv2/lib/alb/application-listener.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-listener.ts#L1005)
- Type last changed: v2.151.0 · 2 Aug 2024

## Example

```ts
import { AutoScalingGroup } from 'aws-cdk-lib/aws-autoscaling';
declare const asg: AutoScalingGroup;
declare const vpc: ec2.Vpc;

// Create the load balancer in a VPC. 'internetFacing' is 'false'
// by default, which creates an internal load balancer.
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
  vpc,
  internetFacing: true
});

// Add a listener and open up the load balancer's security group
// to the world.
const listener = lb.addListener('Listener', {
  port: 80,

  // 'open: true' is the default, you can leave it out if you want. Set it
  // to 'false' and use `listener.connections` if you want to be selective
  // about who can access the load balancer.
  open: true,
});

// Create an AutoScaling group and add it as a load balancing
// target to the listener.
listener.addTargets('ApplicationFleet', {
  port: 8080,
  targets: [asg]
});
```

## Properties

- `conditions`: [ListenerCondition](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.ListenerCondition.html)[] — Rule applies if matches the conditions.

  **Default:** No conditions.

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

  The range is 0-3600 seconds.

- `enableAnomalyMitigation`: boolean = false — Indicates whether anomaly mitigation is enabled.

  Only available when `loadBalancingAlgorithmType` is `TargetGroupLoadBalancingAlgorithmType.WEIGHTED_RANDOM`

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

- `loadBalancingAlgorithmType`: [TargetGroupLoadBalancingAlgorithmType](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.TargetGroupLoadBalancingAlgorithmType.html) = round_robin. — The load balancing algorithm to select targets for routing requests.

- `port`: number — The port on which the listener listens for requests.

  **Default:** Determined from protocol if known

- `priority`: number — Priority of this target group.

  **Default:** Target groups are used as defaults

  The rule with the lowest priority will be used for every request.
  If priority is not given, these target groups will be added as
  defaults, and must not have conditions.

  Priorities must be unique.

- `protocol`: [ApplicationProtocol](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationProtocol.html) — The protocol to use.

  **Default:** Determined from port if known

- `protocolVersion`: [ApplicationProtocolVersion](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationProtocolVersion.html) = ApplicationProtocolVersion.HTTP1 — The protocol version to use.

- `slowStart`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = 0 — The time period during which the load balancer sends a newly registered target a linearly increasing share of the traffic to the target group.

  The range is 30-900 seconds (15 minutes).

- `stickinessCookieDuration`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The stickiness cookie expiration period.

  **Default:** Stickiness disabled

  Setting this value enables load balancer stickiness.

  After this period, the cookie is considered stale. The minimum value is
  1 second and the maximum value is 7 days (604800 seconds).

- `stickinessCookieName`: string — The name of an application-based stickiness cookie.

  **Default:** If `stickinessCookieDuration` is set, a load-balancer generated cookie is used. Otherwise, no stickiness is defined.

  Names that start with the following prefixes are not allowed: AWSALB, AWSALBAPP,
  and AWSALBTG; they're reserved for use by the load balancer.

  Note: `stickinessCookieName` parameter depends on the presence of `stickinessCookieDuration` parameter.
  If `stickinessCookieDuration` is not set, `stickinessCookieName` will be omitted.

- `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`: [IApplicationLoadBalancerTarget](/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.IApplicationLoadBalancerTarget.html)[] — The targets to add to this target group.

  Can be `Instance`, `IPAddress`, or any self-registering load balancing
  target. All target must be of the same type.
