interface InstanceLifecyclePolicy
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.AutoScaling.InstanceLifecyclePolicy |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsautoscaling#InstanceLifecyclePolicy |
Java | software.amazon.awscdk.services.autoscaling.InstanceLifecyclePolicy |
Python | aws_cdk.aws_autoscaling.InstanceLifecyclePolicy |
TypeScript (source) | aws-cdk-lib » aws_autoscaling » InstanceLifecyclePolicy |
Instance lifecycle policy for an Auto Scaling group.
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 |
|---|---|---|
| retention | Retention | Retention triggers for the instance lifecycle policy. |
retentionTriggers?
Type:
Retention
(optional, default: No retention triggers configured)
Retention triggers for the instance lifecycle policy.

.NET
Go
Java
Python
TypeScript (