TerminationPolicy

class aws_cdk.aws_autoscaling.TerminationPolicy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Specifies the termination criteria to apply before Amazon EC2 Auto Scaling chooses an instance for termination.

ExampleMetadata:

infused

Example:

# vpc: ec2.Vpc
# instance_type: ec2.InstanceType
# machine_image: ec2.IMachineImage
# arn: str


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

    # ...

    termination_policies=[autoscaling.TerminationPolicy.CUSTOM_LAMBDA_FUNCTION, autoscaling.TerminationPolicy.OLDEST_INSTANCE, autoscaling.TerminationPolicy.DEFAULT
    ],

    # terminationPolicyCustomLambdaFunctionArn property must be specified if the TerminationPolicy.CUSTOM_LAMBDA_FUNCTION is used
    termination_policy_custom_lambda_function_arn=arn
)

Attributes

ALLOCATION_STRATEGY

Terminate instances in the Auto Scaling group to align the remaining instances to the allocation strategy for the type of instance that is terminating (either a Spot Instance or an On-Demand Instance).

CLOSEST_TO_NEXT_INSTANCE_HOUR

Terminate instances that are closest to the next billing hour.

CUSTOM_LAMBDA_FUNCTION

Terminate instances using custom termination policy with lambda.

If this is specified, you must also supply a value of lambda arn in the terminationPolicyCustomLambdaFunctionArn property.

If there are multiple termination policies specified, the custom termination policy with lambda must be specified first in the order.

See:

https://docs.aws.amazon.com/autoscaling/ec2/userguide/lambda-custom-termination-policy.html#lambda-custom-termination-policy-limitations

DEFAULT

Terminate instances according to the default termination policy.

NEWEST_INSTANCE

Terminate the newest instance in the group.

OLDEST_INSTANCE

Terminate the oldest instance in the group.

OLDEST_LAUNCH_CONFIGURATION

Terminate instances that have the oldest launch configuration.

OLDEST_LAUNCH_TEMPLATE

Terminate instances that have the oldest launch template.