aws-cdk-lib.aws_applicationautoscaling.TargetTrackingScalingPolicy

class TargetTrackingScalingPolicy (construct)

LanguageType name
.NETAmazon.CDK.AWS.ApplicationAutoScaling.TargetTrackingScalingPolicy
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapplicationautoscaling#TargetTrackingScalingPolicy
Javasoftware.amazon.awscdk.services.applicationautoscaling.TargetTrackingScalingPolicy
Pythonaws_cdk.aws_applicationautoscaling.TargetTrackingScalingPolicy
TypeScript (source)aws-cdk-lib » aws_applicationautoscaling » 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_applicationautoscaling as appscaling } from 'aws-cdk-lib';
import { aws_cloudwatch as cloudwatch } from 'aws-cdk-lib';

declare const metric: cloudwatch.Metric;
declare const scalableTarget: appscaling.ScalableTarget;
const targetTrackingScalingPolicy = new appscaling.TargetTrackingScalingPolicy(this, 'MyTargetTrackingScalingPolicy', {
  scalingTarget: scalableTarget,
  targetValue: 123,

  // the properties below are optional
  customMetric: metric,
  disableScaleIn: false,
  policyName: 'policyName',
  predefinedMetric: appscaling.PredefinedMetric.APPSTREAM_AVERAGE_CAPACITY_UTILIZATION,
  resourceLabel: 'resourceLabel',
  scaleInCooldown: cdk.Duration.minutes(30),
  scaleOutCooldown: cdk.Duration.minutes(30),
});

Initializer

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

Parameters

  • scope Construct
  • id string
  • props TargetTrackingScalingPolicyProps

Construct Props

NameTypeDescription
scalingTargetIScalableTarget
targetValuenumberThe target value for the metric.
customMetric?IMetricA custom metric for application autoscaling.
disableScaleIn?booleanIndicates whether scale in by the target tracking policy is disabled.
policyName?stringA name for the scaling policy.
predefinedMetric?PredefinedMetricA predefined metric for application autoscaling.
resourceLabel?stringIdentify the resource associated with the metric type.
scaleInCooldown?DurationPeriod after a scale in activity completes before another scale in activity can start.
scaleOutCooldown?DurationPeriod after a scale out activity completes before another scale out activity can start.

scalingTarget

Type: IScalableTarget


targetValue

Type: number

The target value for the metric.


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 scalable resource. Otherwise, scale in is enabled and the target tracking policy can remove capacity from the scalable resource.


policyName?

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

A name for the scaling policy.


predefinedMetric?

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

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

Identify the resource associated with the metric type.

Only used for predefined metric ALBRequestCountPerTarget.

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


scaleInCooldown?

Type: Duration (optional, default: Duration.seconds(300) for the following scalable targets: ECS services, Spot Fleet requests, EMR clusters, AppStream 2.0 fleets, Aurora DB clusters, Amazon SageMaker endpoint variants, Custom resources. For all other scalable targets, the default value is Duration.seconds(0): DynamoDB tables, DynamoDB global secondary indexes, Amazon Comprehend document classification endpoints, Lambda provisioned concurrency)

Period after a scale in activity completes before another scale in activity can start.


scaleOutCooldown?

Type: Duration (optional, default: Duration.seconds(300) for the following scalable targets: ECS services, Spot Fleet requests, EMR clusters, AppStream 2.0 fleets, Aurora DB clusters, Amazon SageMaker endpoint variants, Custom resources. For all other scalable targets, the default value is Duration.seconds(0): DynamoDB tables, DynamoDB global secondary indexes, Amazon Comprehend document classification endpoints, Lambda provisioned concurrency)

Period after a scale out activity completes before another scale out activity can start.

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.