# HealthCheck

Health check settings.

Obtainable from: HealthCheck.ec2, HealthCheck.elb

- Source: [`aws-autoscaling/lib/auto-scaling-group.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts#L2661)
- Type last changed: v2.182.0 · 5 Mar 2025

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_autoscaling as autoscaling } from 'aws-cdk-lib';
const healthCheck = autoscaling.HealthCheck.ec2(/* all optional props */ {
  grace: cdk.Duration.minutes(30),
});
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_autoscaling as autoscaling

health_check = autoscaling.HealthCheck.ec2(
    grace=cdk.Duration.minutes(30)
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.autoscaling.*;

HealthCheck healthCheck = HealthCheck.ec2(Ec2HealthCheckOptions.builder()
        .grace(Duration.minutes(30))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.AutoScaling;

var healthCheck = HealthCheck.Ec2(new Ec2HealthCheckOptions {
    Grace = Duration.Minutes(30)
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

healthCheck := awscdk.Aws_autoscaling.HealthCheck_Ec2(&Ec2HealthCheckOptions{
	Grace: cdk.Duration_Minutes(jsii.Number(30)),
})
```

## Properties

- `gracePeriod`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html)

- `type`: string

## Methods

- `ec2(options?: Ec2HealthCheckOptions): HealthCheck // chainable` (static) — Use EC2 for health checks.

  **Parameters**

  - `options` — EC2 health check options.

- `elb(options: ElbHealthCheckOptions): HealthCheck // chainable` (static) — Use ELB for health checks.

  It considers the instance unhealthy if it fails either the EC2 status checks or the load balancer health checks.

  **Parameters**

  - `options` — ELB health check options.
