HealthCheck

class HealthCheck : KotlinCustomResource

Health Checks determine whether instances are responsive and able to do work. They are an important part of a comprehensive load balancing configuration, as they enable monitoring instances behind load balancers. Health Checks poll instances at a specified interval. Instances that do not respond successfully to some number of probes in a row are marked as unhealthy. No new connections are sent to unhealthy instances, though existing connections will continue. The health check will continue to poll unhealthy instances. If an instance later responds successfully to some number of consecutive probes, it is marked healthy again and can receive new connections. ~>NOTE: Legacy HTTP(S) health checks must be used for target pool-based network load balancers. See the official guide for choosing a type of health check. To get more information about HealthCheck, see:

Example Usage

Health Check Tcp

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckTcpHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var tcp_health_check = new HealthCheck("tcp-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.tcpHealthCheck(HealthCheckTcpHealthCheckArgs.builder()
.port("80")
.build())
.timeoutSec(1)
.build());
}
}

Health Check Tcp Full

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckTcpHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var tcp_health_check = new HealthCheck("tcp-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.description("Health check via tcp")
.healthyThreshold(4)
.tcpHealthCheck(HealthCheckTcpHealthCheckArgs.builder()
.portName("health-check-port")
.portSpecification("USE_NAMED_PORT")
.proxyHeader("NONE")
.request("ARE YOU HEALTHY?")
.response("I AM HEALTHY")
.build())
.timeoutSec(1)
.unhealthyThreshold(5)
.build());
}
}

Health Check Ssl

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckSslHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var ssl_health_check = new HealthCheck("ssl-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.sslHealthCheck(HealthCheckSslHealthCheckArgs.builder()
.port("443")
.build())
.timeoutSec(1)
.build());
}
}

Health Check Ssl Full

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckSslHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var ssl_health_check = new HealthCheck("ssl-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.description("Health check via ssl")
.healthyThreshold(4)
.sslHealthCheck(HealthCheckSslHealthCheckArgs.builder()
.portName("health-check-port")
.portSpecification("USE_NAMED_PORT")
.proxyHeader("NONE")
.request("ARE YOU HEALTHY?")
.response("I AM HEALTHY")
.build())
.timeoutSec(1)
.unhealthyThreshold(5)
.build());
}
}

Health Check Http

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckHttpHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var http_health_check = new HealthCheck("http-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.httpHealthCheck(HealthCheckHttpHealthCheckArgs.builder()
.port(80)
.build())
.timeoutSec(1)
.build());
}
}

Health Check Http Full

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckHttpHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var http_health_check = new HealthCheck("http-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.description("Health check via http")
.healthyThreshold(4)
.httpHealthCheck(HealthCheckHttpHealthCheckArgs.builder()
.host("1.2.3.4")
.portName("health-check-port")
.portSpecification("USE_NAMED_PORT")
.proxyHeader("NONE")
.requestPath("/mypath")
.response("I AM HEALTHY")
.build())
.timeoutSec(1)
.unhealthyThreshold(5)
.build());
}
}

Health Check Https

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckHttpsHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var https_health_check = new HealthCheck("https-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.httpsHealthCheck(HealthCheckHttpsHealthCheckArgs.builder()
.port("443")
.build())
.timeoutSec(1)
.build());
}
}

Health Check Https Full

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckHttpsHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var https_health_check = new HealthCheck("https-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.description("Health check via https")
.healthyThreshold(4)
.httpsHealthCheck(HealthCheckHttpsHealthCheckArgs.builder()
.host("1.2.3.4")
.portName("health-check-port")
.portSpecification("USE_NAMED_PORT")
.proxyHeader("NONE")
.requestPath("/mypath")
.response("I AM HEALTHY")
.build())
.timeoutSec(1)
.unhealthyThreshold(5)
.build());
}
}

Health Check Http2

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckHttp2HealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var http2_health_check = new HealthCheck("http2-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.http2HealthCheck(HealthCheckHttp2HealthCheckArgs.builder()
.port("443")
.build())
.timeoutSec(1)
.build());
}
}

Health Check Http2 Full

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckHttp2HealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var http2_health_check = new HealthCheck("http2-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.description("Health check via http2")
.healthyThreshold(4)
.http2HealthCheck(HealthCheckHttp2HealthCheckArgs.builder()
.host("1.2.3.4")
.portName("health-check-port")
.portSpecification("USE_NAMED_PORT")
.proxyHeader("NONE")
.requestPath("/mypath")
.response("I AM HEALTHY")
.build())
.timeoutSec(1)
.unhealthyThreshold(5)
.build());
}
}

Health Check Grpc

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckGrpcHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var grpc_health_check = new HealthCheck("grpc-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.grpcHealthCheck(HealthCheckGrpcHealthCheckArgs.builder()
.port("443")
.build())
.timeoutSec(1)
.build());
}
}

Health Check Grpc Full

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckGrpcHealthCheckArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var grpc_health_check = new HealthCheck("grpc-health-check", HealthCheckArgs.builder()
.checkIntervalSec(1)
.grpcHealthCheck(HealthCheckGrpcHealthCheckArgs.builder()
.grpcServiceName("testservice")
.portName("health-check-port")
.portSpecification("USE_NAMED_PORT")
.build())
.timeoutSec(1)
.build());
}
}

Health Check With Logging

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HealthCheck;
import com.pulumi.gcp.compute.HealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckTcpHealthCheckArgs;
import com.pulumi.gcp.compute.inputs.HealthCheckLogConfigArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var health_check_with_logging = new HealthCheck("health-check-with-logging", HealthCheckArgs.builder()
.timeoutSec(1)
.checkIntervalSec(1)
.tcpHealthCheck(HealthCheckTcpHealthCheckArgs.builder()
.port("22")
.build())
.logConfig(HealthCheckLogConfigArgs.builder()
.enable(true)
.build())
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
}
}

Import

HealthCheck can be imported using any of these accepted formats

$ pulumi import gcp:compute/healthCheck:HealthCheck default projects/{{project}}/global/healthChecks/{{name}}
$ pulumi import gcp:compute/healthCheck:HealthCheck default {{project}}/{{name}}
$ pulumi import gcp:compute/healthCheck:HealthCheck default {{name}}

Properties

Link copied to clipboard
val checkIntervalSec: Output<Int>?

How often (in seconds) to send a health check. The default value is 5 seconds.

Link copied to clipboard

Creation timestamp in RFC3339 text format.

Link copied to clipboard
val description: Output<String>?

An optional description of this resource. Provide this property when you create the resource.

Link copied to clipboard

A nested object resource Structure is documented below.

Link copied to clipboard
val healthyThreshold: Output<Int>?

A so-far unhealthy instance will be marked healthy after this many consecutive successes. The default value is 2.

Link copied to clipboard

A nested object resource Structure is documented below.

Link copied to clipboard

A nested object resource Structure is documented below.

Link copied to clipboard

A nested object resource Structure is documented below.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

Configure logging on this health check. Structure is documented below.

Link copied to clipboard
val name: Output<String>

Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

Link copied to clipboard
val project: Output<String>

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val selfLink: Output<String>

The URI of the created resource.

Link copied to clipboard

A nested object resource Structure is documented below.

Link copied to clipboard

A nested object resource Structure is documented below.

Link copied to clipboard
val timeoutSec: Output<Int>?

How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec.

Link copied to clipboard
val type: Output<String>

The type of the health check. One of HTTP, HTTPS, TCP, or SSL.

Link copied to clipboard
val unhealthyThreshold: Output<Int>?

A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2.

Link copied to clipboard
val urn: Output<String>