AWS CDK Auto Scaling Common Library

1.204.0 · maintenance · verified Thu Apr 16

The `aws-cdk-aws-autoscaling-common` package provides shared implementation details for the AWS Cloud Development Kit's `@aws-cdk/aws-autoscaling` and `@aws-cdk/aws-applicationautoscaling` libraries. It is an internal dependency and is not intended for direct use by CDK users. As of version 1.204.0, this package is part of AWS CDK v1, which has reached End-of-Support. Users are encouraged to migrate to AWS CDK v2 and utilize `aws-cdk-lib.aws_autoscaling` and `aws-cdk-lib.aws_applicationautoscaling` directly.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create an EC2 Auto Scaling Group using `aws-cdk-lib.aws_autoscaling` (or the equivalent `aws_cdk.aws_autoscaling` if using CDK v1). This is the recommended way to provision auto-scaling resources. The `aws-cdk-aws-autoscaling-common` package is an underlying dependency and not directly used in user code.

import os
from aws_cdk import (
    App,
    Stack,
    aws_ec2 as ec2,
    aws_autoscaling as autoscaling,
    Duration
)

class AutoScalingStack(Stack):
    def __init__(self, scope: App, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        vpc = ec2.Vpc(self, "MyVpc", max_azs=2)

        asg = autoscaling.AutoScalingGroup(self, "MyASG",
            vpc=vpc,
            instance_type=ec2.InstanceType.of(
                ec2.InstanceClass.BURSTABLE2,
                ec2.InstanceSize.MICRO
            ),
            machine_image=ec2.MachineImage.latest_amazon_linux2(),
            min_capacity=1,
            max_capacity=3
        )

        asg.scale_on_cpu_utilization("CpuScaling",
            target_utilization_percent=50,
            cooldown=Duration.minutes(5)
        )

app = App()
AutoScalingStack(app, "AutoScalingExampleStack")
app.synth()

view raw JSON →