TargetTrackingScalingPolicy

class aws_cdk.aws_autoscaling.TargetTrackingScalingPolicy(scope, id, *, auto_scaling_group, target_value, custom_metric=None, predefined_metric=None, resource_label=None, cooldown=None, disable_scale_in=None, estimated_instance_warmup=None)

Bases: Construct

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_autoscaling as autoscaling
from aws_cdk import aws_cloudwatch as cloudwatch

# auto_scaling_group: autoscaling.AutoScalingGroup
# metric: cloudwatch.Metric

target_tracking_scaling_policy = autoscaling.TargetTrackingScalingPolicy(self, "MyTargetTrackingScalingPolicy",
    auto_scaling_group=auto_scaling_group,
    target_value=123,

    # the properties below are optional
    cooldown=cdk.Duration.minutes(30),
    custom_metric=metric,
    disable_scale_in=False,
    estimated_instance_warmup=cdk.Duration.minutes(30),
    predefined_metric=autoscaling.PredefinedMetric.ASG_AVERAGE_CPU_UTILIZATION,
    resource_label="resourceLabel"
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • auto_scaling_group (IAutoScalingGroup) –

  • target_value (Union[int, float]) – The target value for the metric.

  • custom_metric (Optional[IMetric]) – 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. Default: - No custom metric.

  • predefined_metric (Optional[PredefinedMetric]) – 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. Default: - No predefined metric.

  • resource_label (Optional[str]) – The resource label associated with the predefined metric. Should be supplied if the predefined metric is ALBRequestCountPerTarget, and the format should be: app///targetgroup// Default: - No resource label.

  • cooldown (Optional[Duration]) – Period after a scaling completes before another scaling activity can start. Default: - The default cooldown configured on the AutoScalingGroup.

  • disable_scale_in (Optional[bool]) – 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. Default: false

  • estimated_instance_warmup (Optional[Duration]) – Estimated time until a newly launched instance can send metrics to CloudWatch. Default: - Same as the cooldown.

Methods

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.