UpdatePolicy

class aws_cdk.aws_autoscaling.UpdatePolicy

Bases: object

How existing instances should be updated.

ExampleMetadata:

infused

Example:

# vpc: ec2.Vpc
# instance_type: ec2.InstanceType
# machine_image: ec2.IMachineImage
# alarm: cloudwatch.Alarm


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

    update_policy=autoscaling.UpdatePolicy.instance_refresh(
        strategy=autoscaling.InstanceRefreshStrategy.ROLLING,
        min_healthy_percentage=90,
        max_healthy_percentage=100,
        instance_warmup=Duration.seconds(300),
        checkpoint_percentages=[50, 100],
        checkpoint_delay=Duration.minutes(10),
        alarms=[alarm]
    )
)

Static Methods

classmethod instance_refresh(*, strategy, alarms=None, bake_time=None, checkpoint_delay=None, checkpoint_percentages=None, instance_warmup=None, max_healthy_percentage=None, min_healthy_percentage=None, scale_in_protected_instances=None, skip_matching=None, standby_instances=None)

Use instance refresh to update the instances in the AutoScalingGroup.

When properties that trigger an instance refresh change (such as LaunchTemplate or MixedInstancesPolicy), CloudFormation starts an instance refresh to replace instances gradually while maintaining availability.

Parameters:
  • strategy (InstanceRefreshStrategy) – The strategy to use for the instance refresh.

  • alarms (Optional[Sequence[IAlarmRef]]) – The CloudWatch alarms to monitor during the instance refresh. If any of the alarms goes into ALARM state, the instance refresh fails. You can specify up to 10 alarms. Default: - no alarms

  • bake_time (Optional[Duration]) – The amount of time after an instance refresh completes successfully before CloudFormation considers the update successful. Default: Duration.seconds(0)

  • checkpoint_delay (Optional[Duration]) – The amount of time to wait after a checkpoint is reached before continuing. Default: - 3600 seconds (1 hour), applied only when checkpointPercentages is set

  • checkpoint_percentages (Optional[Sequence[Union[int, float]]]) – Threshold values for each checkpoint in ascending order. Each number must be unique. To replace all instances in the group, the last number in the array must be 100. Default: - no checkpoints

  • instance_warmup (Optional[Duration]) – The amount of time to wait after a new instance enters the InService state before moving on to refresh the next instance. Default: - the group’s DefaultInstanceWarmup if defined; otherwise the group’s HealthCheckGracePeriod

  • max_healthy_percentage (Union[int, float, None]) – The maximum percentage of the group that can be in service and healthy, or pending, to support your workload during the instance refresh. The difference between maxHealthyPercentage and minHealthyPercentage cannot be greater than 100. A larger range increases the number of instances that can be replaced at the same time. Default: - the value set in the Auto Scaling group’s instance maintenance policy, if defined; otherwise 110 when the strategy is Rolling, or 100 when the strategy is ReplaceRootVolume

  • min_healthy_percentage (Union[int, float, None]) – The minimum percentage of the group to keep in service, healthy, and ready to use to support your workload during the instance refresh, expressed as a percentage of the group’s desired capacity. Default: - the value set in the Auto Scaling group’s instance maintenance policy, if defined; otherwise 100 when the strategy is Rolling, or 90 when the strategy is ReplaceRootVolume

  • scale_in_protected_instances (Optional[ScaleInProtectedInstances]) – Specifies the behavior of instances that are protected from scale in during an instance refresh. Default: ScaleInProtectedInstances.WAIT

  • skip_matching (Optional[bool]) – Indicates whether skip matching is enabled. Default: true

  • standby_instances (Optional[StandbyInstances]) – Specifies the behavior of instances in standby during an instance refresh. Default: StandbyInstances.WAIT

Return type:

UpdatePolicy

classmethod replacing_update()

Create a new AutoScalingGroup and switch over to it.

Return type:

UpdatePolicy

classmethod rolling_update(*, max_batch_size=None, min_instances_in_service=None, min_success_percentage=None, pause_time=None, suspend_processes=None, wait_on_resource_signals=None)

Replace the instances in the AutoScalingGroup one by one, or in batches.

Parameters:
  • max_batch_size (Union[int, float, None]) – The maximum number of instances that AWS CloudFormation updates at once. This number affects the speed of the replacement. Default: 1

  • min_instances_in_service (Union[int, float, None]) – The minimum number of instances that must be in service before more instances are replaced. This number affects the speed of the replacement. Default: 0

  • min_success_percentage (Union[int, float, None]) – The percentage of instances that must signal success for the update to succeed. Default: - The minSuccessPercentage configured for signals on the AutoScalingGroup

  • pause_time (Optional[Duration]) – The pause time after making a change to a batch of instances. Default: - The timeout configured for signals on the AutoScalingGroup

  • suspend_processes (Optional[Sequence[ScalingProcess]]) – Specifies the Auto Scaling processes to suspend during a stack update. Suspending processes prevents Auto Scaling from interfering with a stack update. Default: HealthCheck, ReplaceUnhealthy, AZRebalance, AlarmNotification, ScheduledActions.

  • wait_on_resource_signals (Optional[bool]) – Specifies whether the Auto Scaling group waits on signals from new instances during an update. Default: true if you configured signals on the AutoScalingGroup, false otherwise

Return type:

UpdatePolicy