EnableScalingProps

class aws_cdk.aws_applicationautoscaling.EnableScalingProps(*, max_capacity, min_capacity=None)

Bases: object

Properties for enabling Application Auto Scaling.

Parameters
  • max_capacity (Union[int, float]) – Maximum capacity to scale to.

  • min_capacity (Union[int, float, None]) – Minimum capacity to scale to. Default: 1

ExampleMetadata

infused

Example:

# cluster: ecs.Cluster

load_balanced_fargate_service = ecs_patterns.ApplicationLoadBalancedFargateService(self, "Service",
    cluster=cluster,
    memory_limit_mi_b=1024,
    desired_count=1,
    cpu=512,
    task_image_options=ecsPatterns.ApplicationLoadBalancedTaskImageOptions(
        image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample")
    )
)

scalable_target = load_balanced_fargate_service.service.auto_scale_task_count(
    min_capacity=1,
    max_capacity=20
)

scalable_target.scale_on_cpu_utilization("CpuScaling",
    target_utilization_percent=50
)

scalable_target.scale_on_memory_utilization("MemoryScaling",
    target_utilization_percent=50
)

Attributes

max_capacity

Maximum capacity to scale to.

Return type

Union[int, float]

min_capacity

Minimum capacity to scale to.

Default

1

Return type

Union[int, float, None]