Skip to content
v2.275.0

StepScalingAction ​

Define a step scaling action.

This kind of scaling policy adjusts the target capacity in configurable steps. The size of the step is configurable based on the metric's distance to its alarm threshold.

This Action must be used as the target of a CloudWatch alarm to take effect.

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_autoscaling as interfaces_autoscaling } from 'aws-cdk-lib/interfaces';

declare const autoScalingGroupRef: interfaces_autoscaling.IAutoScalingGroupRef;
const stepScalingAction = new autoscaling.StepScalingAction(this, 'MyStepScalingAction', {
  autoScalingGroup: autoScalingGroupRef,

  // the properties below are optional
  adjustmentType: autoscaling.AdjustmentType.CHANGE_IN_CAPACITY,
  cooldown: cdk.Duration.minutes(30),
  estimatedInstanceWarmup: cdk.Duration.minutes(30),
  metricAggregationType: autoscaling.MetricAggregationType.AVERAGE,
  minAdjustmentMagnitude: 123,
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_autoscaling as autoscaling
from aws_cdk.interfaces import aws_autoscaling as interfaces_autoscaling

# auto_scaling_group_ref: interfaces_autoscaling.IAutoScalingGroupRef

step_scaling_action = autoscaling.StepScalingAction(self, "MyStepScalingAction",
    auto_scaling_group=auto_scaling_group_ref,

    # the properties below are optional
    adjustment_type=autoscaling.AdjustmentType.CHANGE_IN_CAPACITY,
    cooldown=cdk.Duration.minutes(30),
    estimated_instance_warmup=cdk.Duration.minutes(30),
    metric_aggregation_type=autoscaling.MetricAggregationType.AVERAGE,
    min_adjustment_magnitude=123
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.autoscaling.*;
import software.amazon.awscdk.interfaces.autoscaling.*;

IAutoScalingGroupRef autoScalingGroupRef;

StepScalingAction stepScalingAction = StepScalingAction.Builder.create(this, "MyStepScalingAction")
        .autoScalingGroup(autoScalingGroupRef)

        // the properties below are optional
        .adjustmentType(AdjustmentType.CHANGE_IN_CAPACITY)
        .cooldown(Duration.minutes(30))
        .estimatedInstanceWarmup(Duration.minutes(30))
        .metricAggregationType(MetricAggregationType.AVERAGE)
        .minAdjustmentMagnitude(123)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.AutoScaling;
using Amazon.CDK.Interfaces.AutoScaling;

IAutoScalingGroupRef autoScalingGroupRef;

var stepScalingAction = new StepScalingAction(this, "MyStepScalingAction", new StepScalingActionProps {
    AutoScalingGroup = autoScalingGroupRef,

    // the properties below are optional
    AdjustmentType = AdjustmentType.CHANGE_IN_CAPACITY,
    Cooldown = Duration.Minutes(30),
    EstimatedInstanceWarmup = Duration.Minutes(30),
    MetricAggregationType = MetricAggregationType.AVERAGE,
    MinAdjustmentMagnitude = 123
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var autoScalingGroupRef IAutoScalingGroupRef

stepScalingAction := awscdk.Aws_autoscaling.NewStepScalingAction(this, jsii.String("MyStepScalingAction"), &StepScalingActionProps{
	AutoScalingGroup: autoScalingGroupRef,

	// the properties below are optional
	AdjustmentType: awscdk.*Aws_autoscaling.AdjustmentType_CHANGE_IN_CAPACITY,
	Cooldown: cdk.Duration_Minutes(jsii.Number(30)),
	EstimatedInstanceWarmup: cdk.Duration_*Minutes(jsii.Number(30)),
	MetricAggregationType: awscdk.*Aws_autoscaling.MetricAggregationType_AVERAGE,
	MinAdjustmentMagnitude: jsii.Number(123),
})

Initializer ​

ts
new StepScalingAction(scope: Construct, id: string, props: StepScalingActionProps)
python
StepScalingAction(scope: Construct, id: str, props: StepScalingActionProps)
java
new StepScalingAction(Construct scope, String id, StepScalingActionProps props)
csharp
new StepScalingAction(Construct scope, string id, StepScalingActionProps props)
go
NewStepScalingAction(Scope Construct, Id *string, Props StepScalingActionProps)

Construct Props ​

adjustmentTypeoptionalAdjustmentTypeadjustment_typeoptionalAdjustmentTypeadjustmentTypeoptionalAdjustmentTypeAdjustmentTypeoptionalAdjustmentTypeAdjustmentTypeoptionalAdjustmentType= ChangeInCapacity#
How the adjustment numbers are interpreted.
autoScalingGroupIAutoScalingGroupRefauto_scaling_groupIAutoScalingGroupRefautoScalingGroupIAutoScalingGroupRefAutoScalingGroupIAutoScalingGroupRefAutoScalingGroupIAutoScalingGroupRefrequired#
The auto scaling group.
cooldownoptionalDurationcooldownoptionalDurationcooldownoptionalDurationCooldownoptionalDurationCooldownoptionalDurationdeprecated#
cooldown is not valid with step scaling action

Default: The default cooldown configured on the AutoScalingGroup

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

Default: Same as the cooldown

metricAggregationTypeoptionalMetricAggregationTypemetric_aggregation_typeoptionalMetricAggregationTypemetricAggregationTypeoptionalMetricAggregationTypeMetricAggregationTypeoptionalMetricAggregationTypeMetricAggregationTypeoptionalMetricAggregationType= Average#
The aggregation type for the CloudWatch metrics.
minAdjustmentMagnitudeoptionalnumbermin_adjustment_magnitudeoptionalint | floatminAdjustmentMagnitudeoptionalNumberMinAdjustmentMagnitudeoptionaldoubleMinAdjustmentMagnitudeoptional*float64#
Minimum absolute number to adjust capacity with as result of percentage scaling.

Default: No minimum scaling effect

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

Properties ​

nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
scalingPolicyArnstringscaling_policy_arnstrscalingPolicyArnStringScalingPolicyArnstringScalingPolicyArn*string#
ARN of the scaling policy.

Methods ​

addAdjustment(adjustment: AdjustmentTier): voiddef add_adjustment(self, adjustment: AdjustmentTier) -> Nonepublic void addAdjustment(AdjustmentTier adjustment)public void AddAdjustment(AdjustmentTier adjustment)func AddAdjustment(Adjustment AdjustmentTier)#
Add an adjustment interval to the ScalingAction.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

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

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func 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.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining