Signals

class aws_cdk.aws_autoscaling.Signals

Bases: object

Configure whether the AutoScalingGroup waits for signals.

If you do configure waiting for signals, you should make sure the instances invoke cfn-signal somewhere in their UserData to signal that they have started up (either successfully or unsuccessfully).

Signals are used both during intial creation and subsequent updates.

Example:

# vpc is of type Vpc
# instance_type is of type InstanceType
# machine_image is of type IMachineImage


autoscaling.AutoScalingGroup(self, "ASG",
    vpc=vpc,
    instance_type=instance_type,
    machine_image=machine_image,

    # ...

    init=ec2.CloudFormationInit.from_elements(
        ec2.InitFile.from_string("/etc/my_instance", "This got written during instance startup")),
    signals=autoscaling.Signals.wait_for_all(
        timeout=Duration.minutes(10)
    )
)

Methods

abstract render_creation_policy(*, desired_capacity=None, min_capacity=None)

Render the ASG’s CreationPolicy.

Parameters
  • desired_capacity (Union[int, float, None]) – The desiredCapacity of the ASG. Default: - desired capacity not configured

  • min_capacity (Union[int, float, None]) – The minSize of the ASG. Default: - minCapacity not configured

Return type

CfnCreationPolicy

Static Methods

classmethod wait_for_all(*, min_success_percentage=None, timeout=None)

Wait for the desiredCapacity of the AutoScalingGroup amount of signals to have been received.

If no desiredCapacity has been configured, wait for minCapacity signals intead.

This number is used during initial creation and during replacing updates. During rolling updates, all updated instances must send a signal.

Parameters
  • min_success_percentage (Union[int, float, None]) – The percentage of signals that need to be successful. If this number is less than 100, a percentage of signals may be failure signals while still succeeding the creation or update in CloudFormation. Default: 100

  • timeout (Optional[Duration]) – How long to wait for the signals to be sent. This should reflect how long it takes your instances to start up (including instance start time and instance initialization time). Default: Duration.minutes(5)

Return type

Signals

classmethod wait_for_count(count, *, min_success_percentage=None, timeout=None)

Wait for a specific amount of signals to have been received.

You should send one signal per instance, so this represents the number of instances to wait for.

This number is used during initial creation and during replacing updates. During rolling updates, all updated instances must send a signal.

Parameters
  • count (Union[int, float]) –

  • min_success_percentage (Union[int, float, None]) – The percentage of signals that need to be successful. If this number is less than 100, a percentage of signals may be failure signals while still succeeding the creation or update in CloudFormation. Default: 100

  • timeout (Optional[Duration]) – How long to wait for the signals to be sent. This should reflect how long it takes your instances to start up (including instance start time and instance initialization time). Default: Duration.minutes(5)

Return type

Signals

classmethod wait_for_min_capacity(*, min_success_percentage=None, timeout=None)

Wait for the minCapacity of the AutoScalingGroup amount of signals to have been received.

This number is used during initial creation and during replacing updates. During rolling updates, all updated instances must send a signal.

Parameters
  • min_success_percentage (Union[int, float, None]) – The percentage of signals that need to be successful. If this number is less than 100, a percentage of signals may be failure signals while still succeeding the creation or update in CloudFormation. Default: 100

  • timeout (Optional[Duration]) – How long to wait for the signals to be sent. This should reflect how long it takes your instances to start up (including instance start time and instance initialization time). Default: Duration.minutes(5)

Return type

Signals