ScalableTarget

class aws_cdk.aws_applicationautoscaling.ScalableTarget(scope, id, *, max_capacity, min_capacity, resource_id, scalable_dimension, service_namespace, role=None)

Bases: aws_cdk.core.Resource

Define a scalable target.

__init__(scope, id, *, max_capacity, min_capacity, resource_id, scalable_dimension, service_namespace, role=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • props

  • max_capacity (Union[int, float]) – The maximum value that Application Auto Scaling can use to scale a target during a scaling activity.

  • min_capacity (Union[int, float]) – The minimum value that Application Auto Scaling can use to scale a target during a scaling activity.

  • resource_id (str) – The resource identifier to associate with this scalable target. This string consists of the resource type and unique identifier.

  • scalable_dimension (str) – The scalable dimension that’s associated with the scalable target. Specify the service namespace, resource type, and scaling property.

  • service_namespace (ServiceNamespace) – The namespace of the AWS service that provides the resource or custom-resource for a resource provided by your own application or service. For valid AWS service namespace values, see the RegisterScalableTarget action in the Application Auto Scaling API Reference.

  • role (Optional[IRole]) – Role that allows Application Auto Scaling to modify your scalable target. Default: A role is automatically created

Return type

None

Methods

add_to_role_policy(statement)

Add a policy statement to the role’s policy.

Parameters

statement (PolicyStatement) –

Return type

None

scale_on_metric(id, *, metric, scaling_steps, adjustment_type=None, cooldown=None, min_adjustment_magnitude=None)

Scale out or in, in response to a metric.

Parameters
  • id (str) –

  • props

  • metric (IMetric) – Metric to scale on.

  • scaling_steps (List[ScalingInterval]) – The intervals for scaling. Maps a range of metric values to a particular scaling behavior.

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

  • cooldown (Optional[Duration]) – 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. Default: No cooldown period

  • 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

Return type

StepScalingPolicy

scale_on_schedule(id, *, schedule, end_time=None, max_capacity=None, min_capacity=None, start_time=None)

Scale out or in based on time.

Parameters
  • id (str) –

  • action

  • schedule (Schedule) – When to perform this action.

  • end_time (Optional[datetime]) – When this scheduled action expires. Default: The rule never expires.

  • max_capacity (Union[int, float, None]) – The new maximum capacity. During the scheduled time, the current capacity is above the maximum capacity, Application Auto Scaling scales in to the maximum capacity. At least one of maxCapacity and minCapacity must be supplied. Default: No new maximum capacity

  • min_capacity (Union[int, float, None]) – The new minimum capacity. During the scheduled time, if the current capacity is below the minimum capacity, Application Auto Scaling scales out to the minimum capacity. At least one of maxCapacity and minCapacity must be supplied. Default: No new minimum capacity

  • start_time (Optional[datetime]) – When this scheduled action becomes active. Default: The rule is activate immediately

Return type

None

scale_to_track_metric(id, *, target_value, custom_metric=None, predefined_metric=None, resource_label=None, disable_scale_in=None, policy_name=None, scale_in_cooldown=None, scale_out_cooldown=None)

Scale out or in in order to keep a metric around a target value.

Parameters
  • id (str) –

  • props

  • 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 metrics.

  • resource_label (Optional[str]) – Identify the resource associated with the metric type. Only used for predefined metric ALBRequestCountPerTarget. Default: - No resource label.

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

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

  • scale_in_cooldown (Optional[Duration]) – Period after a scale in activity completes before another scale in activity can start. Default: - No scale in cooldown.

  • scale_out_cooldown (Optional[Duration]) – Period after a scale out activity completes before another scale out activity can start. Default: - No scale out cooldown.

Return type

TargetTrackingScalingPolicy

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

node

Construct tree node which offers APIs for interacting with the construct tree.

Return type

ConstructNode

role

The role used to give AutoScaling permissions to your resource.

Return type

IRole

scalable_target_id

ID of the Scalable Target.

attribute: :attribute:: true

Example::

# Example may have issues. See https://github.com/aws/jsii/issues/826 service / ecs_stack - MyECSCluster - AB12CDE3F4GH / ecs_stack - MyECSService - AB12CDE3F4GH | ecsservice:DesiredCount|ecs

Return type

str

stack

The stack in which this resource is defined.

Return type

Stack

Static Methods

classmethod from_scalable_target_id(scope, id, scalable_target_id)
Parameters
  • scope (Construct) –

  • id (str) –

  • scalable_target_id (str) –

Return type

IScalableTarget

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool