Skip to content
v2.277.0

HealthCheck Class ​

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

Example ​

ts
const vpc = new ec2.Vpc(this, 'vpc');
const namespace = new cloudmap.PrivateDnsNamespace(this, 'test-namespace', {
    vpc,
    name: 'domain.local',
});
const service = namespace.createService('Svc');

declare const mesh: appmesh.Mesh;
const node = mesh.addVirtualNode('virtual-node', {
  serviceDiscovery: appmesh.ServiceDiscovery.cloudMap(service),
  listeners: [appmesh.VirtualNodeListener.http({
    port: 8081,
    healthCheck: appmesh.HealthCheck.http({
      healthyThreshold: 3,
      interval: Duration.seconds(5), // minimum
      path: '/health-check-path',
      timeout: Duration.seconds(2), // minimum
      unhealthyThreshold: 2,
    }),
  })],
  accessLog: appmesh.AccessLog.fromFilePath('/dev/stdout'),
});
python
# mesh: appmesh.Mesh
vpc = ec2.Vpc(self, "vpc")
namespace = cloudmap.PrivateDnsNamespace(self, "test-namespace",
    vpc=vpc,
    name="domain.local"
)
service = namespace.create_service("Svc")
node = mesh.add_virtual_node("virtual-node",
    service_discovery=appmesh.ServiceDiscovery.cloud_map(service),
    listeners=[appmesh.VirtualNodeListener.http(
        port=8081,
        health_check=appmesh.HealthCheck.http(
            healthy_threshold=3,
            interval=Duration.seconds(5),  # minimum
            path="/health-check-path",
            timeout=Duration.seconds(2),  # minimum
            unhealthy_threshold=2
        )
    )],
    access_log=appmesh.AccessLog.from_file_path("/dev/stdout")
)
java
Mesh mesh;
Vpc vpc = new Vpc(this, "vpc");
PrivateDnsNamespace namespace = PrivateDnsNamespace.Builder.create(this, "test-namespace")
        .vpc(vpc)
        .name("domain.local")
        .build();
Service service = namespace.createService("Svc");
VirtualNode node = mesh.addVirtualNode("virtual-node", VirtualNodeBaseProps.builder()
        .serviceDiscovery(ServiceDiscovery.cloudMap(service))
        .listeners(List.of(VirtualNodeListener.http(HttpVirtualNodeListenerOptions.builder()
                .port(8081)
                .healthCheck(HealthCheck.http(HttpHealthCheckOptions.builder()
                        .healthyThreshold(3)
                        .interval(Duration.seconds(5)) // minimum
                        .path("/health-check-path")
                        .timeout(Duration.seconds(2)) // minimum
                        .unhealthyThreshold(2)
                        .build()))
                .build())))
        .accessLog(AccessLog.fromFilePath("/dev/stdout"))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Mesh mesh;
var vpc = new Vpc(this, "vpc");
var namespace = new PrivateDnsNamespace(this, "test-namespace", new PrivateDnsNamespaceProps {
    Vpc = vpc,
    Name = "domain.local"
});
var service = namespace.CreateService("Svc");
var node = mesh.AddVirtualNode("virtual-node", new VirtualNodeBaseProps {
    ServiceDiscovery = ServiceDiscovery.CloudMap(service),
    Listeners = new [] { VirtualNodeListener.Http(new HttpVirtualNodeListenerOptions {
        Port = 8081,
        HealthCheck = HealthCheck.Http(new HttpHealthCheckOptions {
            HealthyThreshold = 3,
            Interval = Duration.Seconds(5),  // minimum
            Path = "/health-check-path",
            Timeout = Duration.Seconds(2),  // minimum
            UnhealthyThreshold = 2
        })
    }) },
    AccessLog = AccessLog.FromFilePath("/dev/stdout")
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var mesh Mesh
vpc := ec2.NewVpc(this, jsii.String("vpc"))
namespace := cloudmap.NewPrivateDnsNamespace(this, jsii.String("test-namespace"), &PrivateDnsNamespaceProps{
	Vpc: Vpc,
	Name: jsii.String("domain.local"),
})
service := namespace.CreateService(jsii.String("Svc"))
node := mesh.addVirtualNode(jsii.String("virtual-node"), &VirtualNodeBaseProps{
	ServiceDiscovery: appmesh.ServiceDiscovery_CloudMap(service),
	Listeners: []VirtualNodeListener{
		appmesh.VirtualNodeListener_Http(&HttpVirtualNodeListenerOptions{
			Port: jsii.Number(8081),
			HealthCheck: appmesh.HealthCheck_Http(&HttpHealthCheckOptions{
				HealthyThreshold: jsii.Number(3),
				Interval: awscdk.Duration_Seconds(jsii.Number(5)),
				 // minimum
				Path: jsii.String("/health-check-path"),
				Timeout: awscdk.Duration_*Seconds(jsii.Number(2)),
				 // minimum
				UnhealthyThreshold: jsii.Number(2),
			}),
		}),
	},
	AccessLog: appmesh.AccessLog_FromFilePath(jsii.String("/dev/stdout")),
})

Initializer ​

ts
new HealthCheck()
python
HealthCheck()
java
new HealthCheck()
csharp
new HealthCheck()
go
NewHealthCheck()

Methods ​

bind(scope: Construct, options: HealthCheckBindOptions): HealthCheckConfigdef bind(self, scope: Construct, options: HealthCheckBindOptions) -> HealthCheckConfigpublic HealthCheckConfig bind(Construct scope, HealthCheckBindOptions options)public HealthCheckConfig Bind(Construct scope, HealthCheckBindOptions options)func Bind(Scope Construct, Options HealthCheckBindOptions) HealthCheckConfig#
Called when the AccessLog type is initialized.

Can be used to enforce mutual exclusivity with future properties

grpc(options?: GrpcHealthCheckOptions): HealthCheck // chainable@staticmethod def grpc(options: typing.Optional[GrpcHealthCheckOptions] = None) -> HealthCheckpublic static HealthCheck grpc(GrpcHealthCheckOptions options)public static HealthCheck Grpc(GrpcHealthCheckOptions? options = null)func Grpc(Options GrpcHealthCheckOptions) HealthCheckstatic#
Construct a GRPC health check.
http(options?: HttpHealthCheckOptions): HealthCheck // chainable@staticmethod def http(options: typing.Optional[HttpHealthCheckOptions] = None) -> HealthCheckpublic static HealthCheck http(HttpHealthCheckOptions options)public static HealthCheck Http(HttpHealthCheckOptions? options = null)func Http(Options HttpHealthCheckOptions) HealthCheckstatic#
Construct a HTTP health check.
http2(options?: HttpHealthCheckOptions): HealthCheck // chainable@staticmethod def http2(options: typing.Optional[HttpHealthCheckOptions] = None) -> HealthCheckpublic static HealthCheck http2(HttpHealthCheckOptions options)public static HealthCheck Http2(HttpHealthCheckOptions? options = null)func Http2(Options HttpHealthCheckOptions) HealthCheckstatic#
Construct a HTTP2 health check.
tcp(options?: TcpHealthCheckOptions): HealthCheck // chainable@staticmethod def tcp(options: typing.Optional[TcpHealthCheckOptions] = None) -> HealthCheckpublic static HealthCheck tcp(TcpHealthCheckOptions options)public static HealthCheck Tcp(TcpHealthCheckOptions? options = null)func Tcp(Options TcpHealthCheckOptions) HealthCheckstatic#
Construct a TCP health check.