aws-cdk-lib.aws_autoscaling.TargetTrackingScalingPolicy

class TargetTrackingScalingPolicy (construct)

LanguageType name
.NETAmazon.CDK.AWS.AutoScaling.TargetTrackingScalingPolicy
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsautoscaling#TargetTrackingScalingPolicy
Javasoftware.amazon.awscdk.services.autoscaling.TargetTrackingScalingPolicy
Pythonaws_cdk.aws_autoscaling.TargetTrackingScalingPolicy
TypeScript (source)aws-cdk-lib » aws_autoscaling » TargetTrackingScalingPolicy

Implements IConstruct, IDependable

Example

// 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';

declare const autoScalingGroup: autoscaling.AutoScalingGroup;
declare const metric: cloudwatch.Metric;
const targetTrackingScalingPolicy = new autoscaling.TargetTrackingScalingPolicy(this, 'MyTargetTrackingScalingPolicy', {
  autoScalingGroup: autoScalingGroup,
  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

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

Parameters

  • scope Construct
  • id string
  • props TargetTrackingScalingPolicyProps

Construct Props

NameTypeDescription
autoScalingGroupIAutoScalingGroup
targetValuenumberThe target value for the metric.
cooldown?DurationPeriod after a scaling completes before another scaling activity can start.
customMetric?IMetricA custom metric for application autoscaling.
disableScaleIn?booleanIndicates whether scale in by the target tracking policy is disabled.
estimatedInstanceWarmup?DurationEstimated time until a newly launched instance can send metrics to CloudWatch.
predefinedMetric?PredefinedMetricA predefined metric for application autoscaling.
resourceLabel?stringThe resource label associated with the predefined metric.

autoScalingGroup

Type: IAutoScalingGroup


targetValue

Type: number

The target value for the metric.


cooldown?

Type: Duration (optional, default: The default cooldown configured on the AutoScalingGroup.)

Period after a scaling completes before another scaling activity can start.


customMetric?

Type: IMetric (optional, default: No custom metric.)

A custom metric for application autoscaling.

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?

Type: boolean (optional, default: 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?

Type: Duration (optional, default: Same as the cooldown.)

Estimated time until a newly launched instance can send metrics to CloudWatch.


predefinedMetric?

Type: PredefinedMetric (optional, default: No predefined metric.)

A predefined metric for application autoscaling.

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?

Type: string (optional, default: No resource label.)

The resource label associated with the predefined metric.

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>

Properties

NameTypeDescription
nodeNodeThe tree node.
scalingPolicyArnstringARN of the scaling policy.

node

Type: Node

The tree node.


scalingPolicyArn

Type: string

ARN of the scaling policy.

Methods

NameDescription
toString()Returns a string representation of this construct.

toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.