StepScalingAction

class aws_cdk.aws_applicationautoscaling.StepScalingAction(scope, id, *, scaling_target, adjustment_type=None, cooldown=None, metric_aggregation_type=None, min_adjustment_magnitude=None, policy_name=None)

Bases: Construct

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.

ExampleMetadata:

fixture=_generated

Example:

# 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_applicationautoscaling as appscaling

# scalable_target: appscaling.ScalableTarget

step_scaling_action = appscaling.StepScalingAction(self, "MyStepScalingAction",
    scaling_target=scalable_target,

    # the properties below are optional
    adjustment_type=appscaling.AdjustmentType.CHANGE_IN_CAPACITY,
    cooldown=cdk.Duration.minutes(30),
    metric_aggregation_type=appscaling.MetricAggregationType.AVERAGE,
    min_adjustment_magnitude=123,
    policy_name="policyName"
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • scaling_target (IScalableTarget) – The scalable target.

  • adjustment_type (Optional[AdjustmentType]) – How the adjustment numbers are interpreted. Default: ChangeInCapacity

  • cooldown (Optional[Duration]) – Grace period after scaling activity. For scale out policies, multiple scale outs during the cooldown period are squashed so that only the biggest scale out happens. For scale in policies, subsequent scale ins during the cooldown period are ignored. Default: No cooldown period

  • metric_aggregation_type (Optional[MetricAggregationType]) – The aggregation type for the CloudWatch metrics. Default: Average

  • min_adjustment_magnitude (Union[int, float, None]) – 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. Default: No minimum scaling effect

  • policy_name (Optional[str]) – A name for the scaling policy. Default: Automatically generated name

Methods

add_adjustment(*, adjustment, lower_bound=None, upper_bound=None)

Add an adjusment interval to the ScalingAction.

Parameters:
  • adjustment (Union[int, float]) – What number to adjust the capacity with. The number is interpeted as an added capacity, a new fixed capacity or an added percentage depending on the AdjustmentType value of the StepScalingPolicy. Can be positive or negative.

  • lower_bound (Union[int, float, None]) – Lower bound where this scaling tier applies. The scaling tier applies if the difference between the metric value and its alarm threshold is higher than this value. Default: -Infinity if this is the first tier, otherwise the upperBound of the previous tier

  • upper_bound (Union[int, float, None]) – Upper bound where this scaling tier applies. The scaling tier applies if the difference between the metric value and its alarm threshold is lower than this value. Default: +Infinity

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

node

The tree node.

scaling_policy_arn

ARN of the scaling policy.

Static Methods

classmethod is_construct(x)

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) – Any object.

Return type:

bool

Returns:

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