interface RetentionTriggers
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.AutoScaling.RetentionTriggers |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsautoscaling#RetentionTriggers |
Java | software.amazon.awscdk.services.autoscaling.RetentionTriggers |
Python | aws_cdk.aws_autoscaling.RetentionTriggers |
TypeScript (source) | aws-cdk-lib » aws_autoscaling » RetentionTriggers |
Defines the specific triggers that cause instances to be retained in a Retained state rather than terminated.
Each trigger corresponds to a different failure scenario during the instance lifecycle. This allows fine-grained control over when to preserve instances for manual intervention.
Example
declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;
declare const machineImage: ec2.IMachineImage;
const asg = new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType,
machineImage,
// Configure instance lifecycle policy
instanceLifecyclePolicy: {
retentionTriggers: {
terminateHookAbandon: autoscaling.TerminateHookAbandonAction.RETAIN,
},
},
});
// Add termination lifecycle hook (required for the policy to take effect)
asg.addLifecycleHook('TerminationHook', {
lifecycleTransition: autoscaling.LifecycleTransition.INSTANCE_TERMINATING,
});
Properties
| Name | Type | Description |
|---|---|---|
| terminate | Terminate | Specifies the action when a termination lifecycle hook is abandoned due to failure, timeout, or explicit abandonment (calling CompleteLifecycleAction). |
terminateHookAbandon?
Type:
Terminate
(optional, default: No action specified)
Specifies the action when a termination lifecycle hook is abandoned due to failure, timeout, or explicit abandonment (calling CompleteLifecycleAction).
Set to Retain to move instances to a Retained state. Set to Terminate for default termination behavior.
Retained instances don't count toward desired capacity and remain until you call TerminateInstanceInAutoScalingGroup.

.NET
Go
Java
Python
TypeScript (