aws-cdk-lib.aws_applicationautoscaling.StepScalingPolicy

class StepScalingPolicy (construct)

LanguageType name
.NETAmazon.CDK.AWS.ApplicationAutoScaling.StepScalingPolicy
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapplicationautoscaling#StepScalingPolicy
Javasoftware.amazon.awscdk.services.applicationautoscaling.StepScalingPolicy
Pythonaws_cdk.aws_applicationautoscaling.StepScalingPolicy
TypeScript (source)aws-cdk-lib » aws_applicationautoscaling » StepScalingPolicy

Implements IConstruct, IDependable

Define a scaling strategy which scales depending on absolute values of some metric.

You can specify the scaling behavior for various values of the metric.

Implemented using one or more CloudWatch alarms and Step Scaling Policies.

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 stepScalingPolicy = new appscaling.StepScalingPolicy(this, 'MyStepScalingPolicy', {
  metric: metric,
  scalingSteps: [{
    change: 123,

    // the properties below are optional
    lower: 123,
    upper: 123,
  }],
  scalingTarget: scalableTarget,

  // the properties below are optional
  adjustmentType: appscaling.AdjustmentType.CHANGE_IN_CAPACITY,
  cooldown: cdk.Duration.minutes(30),
  datapointsToAlarm: 123,
  evaluationPeriods: 123,
  metricAggregationType: appscaling.MetricAggregationType.AVERAGE,
  minAdjustmentMagnitude: 123,
});

Initializer

new StepScalingPolicy(scope: Construct, id: string, props: StepScalingPolicyProps)

Parameters

  • scope Construct
  • id string
  • props StepScalingPolicyProps

Construct Props

NameTypeDescription
metricIMetricMetric to scale on.
scalingStepsScalingInterval[]The intervals for scaling.
scalingTargetIScalableTargetThe scaling target.
adjustmentType?AdjustmentTypeHow the adjustment numbers inside 'intervals' are interpreted.
cooldown?DurationGrace period after scaling activity.
datapointsToAlarm?numberThe number of data points out of the evaluation periods that must be breaching to trigger a scaling action.
evaluationPeriods?numberHow many evaluation periods of the metric to wait before triggering a scaling action.
metricAggregationType?MetricAggregationTypeAggregation to apply to all data points over the evaluation periods.
minAdjustmentMagnitude?numberMinimum absolute number to adjust capacity with as result of percentage scaling.

metric

Type: IMetric

Metric to scale on.


scalingSteps

Type: ScalingInterval[]

The intervals for scaling.

Maps a range of metric values to a particular scaling behavior.


scalingTarget

Type: IScalableTarget

The scaling target.


adjustmentType?

Type: AdjustmentType (optional, default: ChangeInCapacity)

How the adjustment numbers inside 'intervals' are interpreted.


cooldown?

Type: Duration (optional, default: No cooldown period)

Grace period after scaling activity.

Subsequent scale outs during the cooldown period are squashed so that only the biggest scale out happens.

Subsequent scale ins during the cooldown period are ignored.

See also: https://docs.aws.amazon.com/autoscaling/application/APIReference/API_StepScalingPolicyConfiguration.html


datapointsToAlarm?

Type: number (optional, default: evaluationPeriods)

The number of data points out of the evaluation periods that must be breaching to trigger a scaling action.

Creates an "M out of N" alarm, where this property is the M and the value set for evaluationPeriods is the N value.

Only has meaning if evaluationPeriods != 1.


evaluationPeriods?

Type: number (optional, default: 1)

How many evaluation periods of the metric to wait before triggering a scaling action.

Raising this value can be used to smooth out the metric, at the expense of slower response times.

If datapointsToAlarm is not set, then all data points in the evaluation period must meet the criteria to trigger a scaling action.


metricAggregationType?

Type: MetricAggregationType (optional, default: The statistic from the metric if applicable (MIN, MAX, AVERAGE), otherwise AVERAGE.)

Aggregation to apply to all data points over the evaluation periods.

Only has meaning if evaluationPeriods != 1.


minAdjustmentMagnitude?

Type: number (optional, default: No minimum scaling effect)

Minimum absolute number to adjust capacity with as result of percentage scaling.

Only when using AdjustmentType = PercentChangeInCapacity, this number controls the minimum absolute effect size.

Properties

NameTypeDescription
nodeNodeThe tree node.
lowerAction?StepScalingAction
lowerAlarm?Alarm
upperAction?StepScalingAction
upperAlarm?Alarm

node

Type: Node

The tree node.


lowerAction?

Type: StepScalingAction (optional)


lowerAlarm?

Type: Alarm (optional)


upperAction?

Type: StepScalingAction (optional)


upperAlarm?

Type: Alarm (optional)

Methods

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

toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.