# TargetTrackingScalingPolicy

Extends: Construct › TargetTrackingScalingPolicy
Implements: IConstruct, IDependable

- Source: [`aws-autoscaling/lib/target-tracking-scaling-policy.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-autoscaling/lib/target-tracking-scaling-policy.ts#L103)

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_autoscaling as autoscaling } from 'aws-cdk-lib';
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';
import { aws_autoscaling as interfaces_autoscaling } from 'aws-cdk-lib/interfaces';

declare const autoScalingGroupRef: interfaces_autoscaling.IAutoScalingGroupRef;
declare const metric: cloudwatch.Metric;
const targetTrackingScalingPolicy = new autoscaling.TargetTrackingScalingPolicy(this, 'MyTargetTrackingScalingPolicy', {
  autoScalingGroup: autoScalingGroupRef,
  targetValue: 123,

  // the properties below are optional
  cooldown: cdk.Duration.minutes(30),
  customMetric: metric,
  disableScaleIn: false,
  estimatedInstanceWarmup: cdk.Duration.minutes(30),
  predefinedMetric: autoscaling.PredefinedMetric.ASG_AVERAGE_CPU_UTILIZATION,
  resourceLabel: 'resourceLabel',
});
```

## Initializer

```ts
new TargetTrackingScalingPolicy(scope: Construct, id: string, props: TargetTrackingScalingPolicyProps)
```

## Construct Props

- `autoScalingGroup`: [IAutoScalingGroupRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_autoscaling.IAutoScalingGroupRef.html) (required)

- `cooldown`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — Period after a scaling completes before another scaling activity can start.

  **Default:** The default cooldown configured on the AutoScalingGroup.

- `customMetric`: [IMetric](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.IMetric.html) — A custom metric for application autoscaling.

  **Default:** No custom metric.

  The metric must track utilization. Scaling out will happen if the metric is higher than
  the target value, scaling in will happen in the metric is lower than the target value.

  Exactly one of customMetric or predefinedMetric must be specified.

- `disableScaleIn`: boolean = false — Indicates whether scale in by the target tracking policy is disabled.

  If the value is true, scale in is disabled and the target tracking policy
  won't remove capacity from the autoscaling group. Otherwise, scale in is
  enabled and the target tracking policy can remove capacity from the
  group.

- `estimatedInstanceWarmup`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — Estimated time until a newly launched instance can send metrics to CloudWatch.

  **Default:** Same as the cooldown.

- `predefinedMetric`: [PredefinedMetric](/cdk/api/v2/docs/aws-cdk-lib.aws_autoscaling.PredefinedMetric.html) — A predefined metric for application autoscaling.

  **Default:** No predefined metric.

  The metric must track utilization. Scaling out will happen if the metric is higher than
  the target value, scaling in will happen in the metric is lower than the target value.

  Exactly one of customMetric or predefinedMetric must be specified.

- `resourceLabel`: string — The resource label associated with the predefined metric.

  **Default:** No resource label.

  Should be supplied if the predefined metric is ALBRequestCountPerTarget, and the
  format should be:

  app/<load-balancer-name>/<load-balancer-id>/targetgroup/<target-group-name>/<target-group-id>

- `targetValue`: number (required) — The target value for the metric.

## Properties

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

- `scalingPolicyArn`: string — ARN of the scaling policy.

## Methods

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

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