Enum TerminationPolicy

java.lang.Object
java.lang.Enum<TerminationPolicy>
software.amazon.awscdk.services.autoscaling.TerminationPolicy
All Implemented Interfaces:
Serializable, Comparable<TerminationPolicy>, java.lang.constant.Constable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-06T23:25:04.721Z") @Stability(Stable) public enum TerminationPolicy extends Enum<TerminationPolicy>
Specifies the termination criteria to apply before Amazon EC2 Auto Scaling chooses an instance for termination.

Example:

 Vpc vpc;
 InstanceType instanceType;
 IMachineImage machineImage;
 String arn;
 AutoScalingGroup.Builder.create(this, "ASG")
         .vpc(vpc)
         .instanceType(instanceType)
         .machineImage(machineImage)
         // ...
         .terminationPolicies(List.of(TerminationPolicy.CUSTOM_LAMBDA_FUNCTION, TerminationPolicy.OLDEST_INSTANCE, TerminationPolicy.DEFAULT))
         //terminationPolicyCustomLambdaFunctionArn property must be specified if the TerminationPolicy.CUSTOM_LAMBDA_FUNCTION is used
         .terminationPolicyCustomLambdaFunctionArn(arn)
         .build();
 
  • Enum Constant Details

    • ALLOCATION_STRATEGY

      @Stability(Stable) public static final TerminationPolicy 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

      @Stability(Stable) public static final TerminationPolicy CLOSEST_TO_NEXT_INSTANCE_HOUR
      Terminate instances that are closest to the next billing hour.
    • DEFAULT

      @Stability(Stable) public static final TerminationPolicy DEFAULT
      Terminate instances according to the default termination policy.
    • NEWEST_INSTANCE

      @Stability(Stable) public static final TerminationPolicy NEWEST_INSTANCE
      Terminate the newest instance in the group.
    • OLDEST_INSTANCE

      @Stability(Stable) public static final TerminationPolicy OLDEST_INSTANCE
      Terminate the oldest instance in the group.
    • OLDEST_LAUNCH_CONFIGURATION

      @Stability(Stable) public static final TerminationPolicy OLDEST_LAUNCH_CONFIGURATION
      Terminate instances that have the oldest launch configuration.
    • OLDEST_LAUNCH_TEMPLATE

      @Stability(Stable) public static final TerminationPolicy OLDEST_LAUNCH_TEMPLATE
      Terminate instances that have the oldest launch template.
    • CUSTOM_LAMBDA_FUNCTION

      @Stability(Stable) public static final TerminationPolicy 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 Also:
  • Method Details

    • values

      public static TerminationPolicy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static TerminationPolicy valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null