> **Experimental**
>
> `@aws-cdk/aws-apprunner-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# HealthCheck

Contains static factory methods for creating health checks for different protocols.

Obtainable from: HealthCheck.http, HealthCheck.tcp

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/service.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts#L991)

## Example

TypeScript:

```ts
new apprunner.Service(this, 'Service', {
  source: apprunner.Source.fromEcrPublic({
    imageConfiguration: { port: 8000 },
    imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
  }),
  healthCheck: apprunner.HealthCheck.http({
    healthyThreshold: 5,
    interval: Duration.seconds(10),
    path: '/',
    timeout: Duration.seconds(10),
    unhealthyThreshold: 10,
  }),
});
```

Python:

```python
apprunner.Service(self, "Service",
    source=apprunner.Source.from_ecr_public(
        image_configuration=apprunner.ImageConfiguration(port=8000),
        image_identifier="public.ecr.aws/aws-containers/hello-app-runner:latest"
    ),
    health_check=apprunner.HealthCheck.http(
        healthy_threshold=5,
        interval=Duration.seconds(10),
        path="/",
        timeout=Duration.seconds(10),
        unhealthy_threshold=10
    )
)
```

Java:

```java
Service.Builder.create(this, "Service")
        .source(Source.fromEcrPublic(EcrPublicProps.builder()
                .imageConfiguration(ImageConfiguration.builder().port(8000).build())
                .imageIdentifier("public.ecr.aws/aws-containers/hello-app-runner:latest")
                .build()))
        .healthCheck(HealthCheck.http(HttpHealthCheckOptions.builder()
                .healthyThreshold(5)
                .interval(Duration.seconds(10))
                .path("/")
                .timeout(Duration.seconds(10))
                .unhealthyThreshold(10)
                .build()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.AppRunner.Alpha
new Service(this, "Service", new ServiceProps {
    Source = Source.FromEcrPublic(new EcrPublicProps {
        ImageConfiguration = new ImageConfiguration { Port = 8000 },
        ImageIdentifier = "public.ecr.aws/aws-containers/hello-app-runner:latest"
    }),
    HealthCheck = HealthCheck.Http(new HttpHealthCheckOptions {
        HealthyThreshold = 5,
        Interval = Duration.Seconds(10),
        Path = "/",
        Timeout = Duration.Seconds(10),
        UnhealthyThreshold = 10
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkapprunneralpha/v2
apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
	Source: apprunner.Source_FromEcrPublic(&EcrPublicProps{
		ImageConfiguration: &ImageConfiguration{
			Port: jsii.Number(8000),
		},
		ImageIdentifier: jsii.String("public.ecr.aws/aws-containers/hello-app-runner:latest"),
	}),
	HealthCheck: apprunner.HealthCheck_Http(&HttpHealthCheckOptions{
		HealthyThreshold: jsii.Number(5),
		Interval: awscdk.Duration_Seconds(jsii.Number(10)),
		Path: jsii.String("/"),
		Timeout: awscdk.Duration_*Seconds(jsii.Number(10)),
		UnhealthyThreshold: jsii.Number(10),
	}),
})
```

## Properties

- `healthCheckProtocolType`: [HealthCheckProtocolType](/cdk/api/v2/docs/@aws-cdk_aws-apprunner-alpha.HealthCheckProtocolType.html)

- `healthyThreshold`: number

- `interval`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html)

- `path`: string

- `timeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html)

- `unhealthyThreshold`: number

## Methods

- `bind(): CfnService.HealthCheckConfigurationProperty`

- `http(options?: HttpHealthCheckOptions): HealthCheck // chainable` (static) — Construct a HTTP health check.

- `tcp(options?: TcpHealthCheckOptions): HealthCheck // chainable` (static) — Construct a TCP health check.
