@@ -156,6 +156,13 @@ export interface CommonAutoScalingGroupProps {
156
156
* @default none
157
157
*/
158
158
readonly spotPrice ?: string ;
159
+
160
+ /**
161
+ * Configuration for health checks
162
+ *
163
+ * @default - HealthCheck.ec2 with no grace period
164
+ */
165
+ readonly healthCheck ?: HealthCheck ;
159
166
}
160
167
161
168
/**
@@ -444,7 +451,9 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
444
451
] ,
445
452
}
446
453
] ,
447
- vpcZoneIdentifier : subnetIds
454
+ vpcZoneIdentifier : subnetIds ,
455
+ healthCheckType : props . healthCheck && props . healthCheck . type ,
456
+ healthCheckGracePeriod : props . healthCheck && props . healthCheck . gracePeriod && props . healthCheck . gracePeriod . toSeconds ( ) ,
448
457
} ;
449
458
450
459
if ( ! hasPublic && props . associatePublicIpAddress ) {
@@ -673,6 +682,61 @@ export enum ScalingProcess {
673
682
ADD_TO_LOAD_BALANCER = 'AddToLoadBalancer'
674
683
}
675
684
685
+ /**
686
+ * EC2 Heath check options
687
+ */
688
+ export interface Ec2HealthCheckOptions {
689
+ /**
690
+ * Specified the time Auto Scaling waits before checking the health status of an EC2 instance that has come into service
691
+ *
692
+ * @default Duration.seconds(0)
693
+ */
694
+ readonly grace ?: Duration ;
695
+ }
696
+
697
+ /**
698
+ * ELB Heath check options
699
+ */
700
+ export interface ElbHealthCheckOptions {
701
+ /**
702
+ * Specified the time Auto Scaling waits before checking the health status of an EC2 instance that has come into service
703
+ *
704
+ * This option is required for ELB health checks.
705
+ */
706
+ readonly grace : Duration ;
707
+ }
708
+
709
+ /**
710
+ * Health check settings
711
+ */
712
+ export class HealthCheck {
713
+ /**
714
+ * Use EC2 for health checks
715
+ *
716
+ * @param options EC2 health check options
717
+ */
718
+ public static ec2 ( options : Ec2HealthCheckOptions = { } ) : HealthCheck {
719
+ return new HealthCheck ( HealthCheckType . EC2 , options . grace ) ;
720
+ }
721
+
722
+ /**
723
+ * Use ELB for health checks.
724
+ * It considers the instance unhealthy if it fails either the EC2 status checks or the load balancer health checks.
725
+ *
726
+ * @param options ELB health check options
727
+ */
728
+ public static elb ( options : ElbHealthCheckOptions ) : HealthCheck {
729
+ return new HealthCheck ( HealthCheckType . ELB , options . grace ) ;
730
+ }
731
+
732
+ private constructor ( public readonly type : string , public readonly gracePeriod ?: Duration ) { }
733
+ }
734
+
735
+ enum HealthCheckType {
736
+ EC2 = 'EC2' ,
737
+ ELB = 'ELB' ,
738
+ }
739
+
676
740
/**
677
741
* Render the rolling update configuration into the appropriate object
678
742
*/
0 commit comments