Configure GCP Compute Health Checks

The gcp:compute/healthCheck:HealthCheck resource, part of the Pulumi GCP provider, defines health checks that poll instances at regular intervals to determine if they can receive traffic. This guide focuses on three capabilities: HTTP and HTTPS endpoint monitoring, gRPC service health verification, and logging and regional probe control.

Health checks monitor backend instances or services and are referenced by load balancers and backend services. The examples are intentionally small. Combine them with your own backend services and load balancing configuration.

Check HTTP endpoints with minimal configuration

Most load balancing deployments start with HTTP health checks that verify web servers respond on standard ports.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const http_health_check = new gcp.compute.HealthCheck("http-health-check", {
    name: "http-health-check",
    timeoutSec: 1,
    checkIntervalSec: 1,
    httpHealthCheck: {
        port: 80,
    },
});
import pulumi
import pulumi_gcp as gcp

http_health_check = gcp.compute.HealthCheck("http-health-check",
    name="http-health-check",
    timeout_sec=1,
    check_interval_sec=1,
    http_health_check={
        "port": 80,
    })
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewHealthCheck(ctx, "http-health-check", &compute.HealthCheckArgs{
			Name:             pulumi.String("http-health-check"),
			TimeoutSec:       pulumi.Int(1),
			CheckIntervalSec: pulumi.Int(1),
			HttpHealthCheck: &compute.HealthCheckHttpHealthCheckArgs{
				Port: pulumi.Int(80),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var http_health_check = new Gcp.Compute.HealthCheck("http-health-check", new()
    {
        Name = "http-health-check",
        TimeoutSec = 1,
        CheckIntervalSec = 1,
        HttpHealthCheck = new Gcp.Compute.Inputs.HealthCheckHttpHealthCheckArgs
        {
            Port = 80,
        },
    });

});
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()
            .name("http-health-check")
            .timeoutSec(1)
            .checkIntervalSec(1)
            .httpHealthCheck(HealthCheckHttpHealthCheckArgs.builder()
                .port(80)
                .build())
            .build());

    }
}
resources:
  http-health-check:
    type: gcp:compute:HealthCheck
    properties:
      name: http-health-check
      timeoutSec: 1
      checkIntervalSec: 1
      httpHealthCheck:
        port: 80

The httpHealthCheck property configures the protocol and port. The timeoutSec and checkIntervalSec properties control how long to wait for responses and how often to probe. Instances that don’t respond within the timeout are marked unhealthy after consecutive failures.

Validate HTTP responses with custom paths and thresholds

Production HTTP services often expose dedicated health endpoints that return specific responses.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const http_health_check = new gcp.compute.HealthCheck("http-health-check", {
    name: "http-health-check",
    description: "Health check via http",
    timeoutSec: 1,
    checkIntervalSec: 1,
    healthyThreshold: 4,
    unhealthyThreshold: 5,
    httpHealthCheck: {
        portName: "health-check-port",
        portSpecification: "USE_NAMED_PORT",
        host: "1.2.3.4",
        requestPath: "/mypath",
        proxyHeader: "NONE",
        response: "I AM HEALTHY",
    },
});
import pulumi
import pulumi_gcp as gcp

http_health_check = gcp.compute.HealthCheck("http-health-check",
    name="http-health-check",
    description="Health check via http",
    timeout_sec=1,
    check_interval_sec=1,
    healthy_threshold=4,
    unhealthy_threshold=5,
    http_health_check={
        "port_name": "health-check-port",
        "port_specification": "USE_NAMED_PORT",
        "host": "1.2.3.4",
        "request_path": "/mypath",
        "proxy_header": "NONE",
        "response": "I AM HEALTHY",
    })
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewHealthCheck(ctx, "http-health-check", &compute.HealthCheckArgs{
			Name:               pulumi.String("http-health-check"),
			Description:        pulumi.String("Health check via http"),
			TimeoutSec:         pulumi.Int(1),
			CheckIntervalSec:   pulumi.Int(1),
			HealthyThreshold:   pulumi.Int(4),
			UnhealthyThreshold: pulumi.Int(5),
			HttpHealthCheck: &compute.HealthCheckHttpHealthCheckArgs{
				PortName:          pulumi.String("health-check-port"),
				PortSpecification: pulumi.String("USE_NAMED_PORT"),
				Host:              pulumi.String("1.2.3.4"),
				RequestPath:       pulumi.String("/mypath"),
				ProxyHeader:       pulumi.String("NONE"),
				Response:          pulumi.String("I AM HEALTHY"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var http_health_check = new Gcp.Compute.HealthCheck("http-health-check", new()
    {
        Name = "http-health-check",
        Description = "Health check via http",
        TimeoutSec = 1,
        CheckIntervalSec = 1,
        HealthyThreshold = 4,
        UnhealthyThreshold = 5,
        HttpHealthCheck = new Gcp.Compute.Inputs.HealthCheckHttpHealthCheckArgs
        {
            PortName = "health-check-port",
            PortSpecification = "USE_NAMED_PORT",
            Host = "1.2.3.4",
            RequestPath = "/mypath",
            ProxyHeader = "NONE",
            Response = "I AM HEALTHY",
        },
    });

});
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()
            .name("http-health-check")
            .description("Health check via http")
            .timeoutSec(1)
            .checkIntervalSec(1)
            .healthyThreshold(4)
            .unhealthyThreshold(5)
            .httpHealthCheck(HealthCheckHttpHealthCheckArgs.builder()
                .portName("health-check-port")
                .portSpecification("USE_NAMED_PORT")
                .host("1.2.3.4")
                .requestPath("/mypath")
                .proxyHeader("NONE")
                .response("I AM HEALTHY")
                .build())
            .build());

    }
}
resources:
  http-health-check:
    type: gcp:compute:HealthCheck
    properties:
      name: http-health-check
      description: Health check via http
      timeoutSec: 1
      checkIntervalSec: 1
      healthyThreshold: 4
      unhealthyThreshold: 5
      httpHealthCheck:
        portName: health-check-port
        portSpecification: USE_NAMED_PORT
        host: 1.2.3.4
        requestPath: /mypath
        proxyHeader: NONE
        response: I AM HEALTHY

The requestPath property targets a specific endpoint, and the response property validates the returned content. The healthyThreshold and unhealthyThreshold properties control how many consecutive successes or failures trigger state changes. The portSpecification set to USE_NAMED_PORT allows the check to use a named port configured on the instance group rather than a fixed port number.

Check HTTPS endpoints with TLS

Services that require encrypted connections need HTTPS health checks to verify both availability and TLS configuration.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const https_health_check = new gcp.compute.HealthCheck("https-health-check", {
    name: "https-health-check",
    timeoutSec: 1,
    checkIntervalSec: 1,
    httpsHealthCheck: {
        port: 443,
    },
});
import pulumi
import pulumi_gcp as gcp

https_health_check = gcp.compute.HealthCheck("https-health-check",
    name="https-health-check",
    timeout_sec=1,
    check_interval_sec=1,
    https_health_check={
        "port": 443,
    })
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewHealthCheck(ctx, "https-health-check", &compute.HealthCheckArgs{
			Name:             pulumi.String("https-health-check"),
			TimeoutSec:       pulumi.Int(1),
			CheckIntervalSec: pulumi.Int(1),
			HttpsHealthCheck: &compute.HealthCheckHttpsHealthCheckArgs{
				Port: pulumi.Int(443),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var https_health_check = new Gcp.Compute.HealthCheck("https-health-check", new()
    {
        Name = "https-health-check",
        TimeoutSec = 1,
        CheckIntervalSec = 1,
        HttpsHealthCheck = new Gcp.Compute.Inputs.HealthCheckHttpsHealthCheckArgs
        {
            Port = 443,
        },
    });

});
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()
            .name("https-health-check")
            .timeoutSec(1)
            .checkIntervalSec(1)
            .httpsHealthCheck(HealthCheckHttpsHealthCheckArgs.builder()
                .port(443)
                .build())
            .build());

    }
}
resources:
  https-health-check:
    type: gcp:compute:HealthCheck
    properties:
      name: https-health-check
      timeoutSec: 1
      checkIntervalSec: 1
      httpsHealthCheck:
        port: '443'

The httpsHealthCheck property configures TLS-encrypted probes on port 443. The health check validates that instances respond successfully over HTTPS, verifying both service availability and TLS configuration.

Check gRPC services without TLS

gRPC services expose health check endpoints through the gRPC Health Checking Protocol, allowing load balancers to verify service readiness.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const grpc_health_check = new gcp.compute.HealthCheck("grpc-health-check", {
    name: "grpc-health-check",
    timeoutSec: 1,
    checkIntervalSec: 1,
    grpcHealthCheck: {
        port: 443,
    },
});
import pulumi
import pulumi_gcp as gcp

grpc_health_check = gcp.compute.HealthCheck("grpc-health-check",
    name="grpc-health-check",
    timeout_sec=1,
    check_interval_sec=1,
    grpc_health_check={
        "port": 443,
    })
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewHealthCheck(ctx, "grpc-health-check", &compute.HealthCheckArgs{
			Name:             pulumi.String("grpc-health-check"),
			TimeoutSec:       pulumi.Int(1),
			CheckIntervalSec: pulumi.Int(1),
			GrpcHealthCheck: &compute.HealthCheckGrpcHealthCheckArgs{
				Port: pulumi.Int(443),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var grpc_health_check = new Gcp.Compute.HealthCheck("grpc-health-check", new()
    {
        Name = "grpc-health-check",
        TimeoutSec = 1,
        CheckIntervalSec = 1,
        GrpcHealthCheck = new Gcp.Compute.Inputs.HealthCheckGrpcHealthCheckArgs
        {
            Port = 443,
        },
    });

});
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()
            .name("grpc-health-check")
            .timeoutSec(1)
            .checkIntervalSec(1)
            .grpcHealthCheck(HealthCheckGrpcHealthCheckArgs.builder()
                .port(443)
                .build())
            .build());

    }
}
resources:
  grpc-health-check:
    type: gcp:compute:HealthCheck
    properties:
      name: grpc-health-check
      timeoutSec: 1
      checkIntervalSec: 1
      grpcHealthCheck:
        port: '443'

The grpcHealthCheck property configures gRPC protocol probes. The health check uses the standard gRPC health checking service to verify that the service is ready to accept requests.

Check specific gRPC services by name

When multiple gRPC services run on the same port, you can target specific services by name to verify their individual health status.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const grpc_health_check = new gcp.compute.HealthCheck("grpc-health-check", {
    name: "grpc-health-check",
    timeoutSec: 1,
    checkIntervalSec: 1,
    grpcHealthCheck: {
        portName: "health-check-port",
        portSpecification: "USE_NAMED_PORT",
        grpcServiceName: "testservice",
    },
});
import pulumi
import pulumi_gcp as gcp

grpc_health_check = gcp.compute.HealthCheck("grpc-health-check",
    name="grpc-health-check",
    timeout_sec=1,
    check_interval_sec=1,
    grpc_health_check={
        "port_name": "health-check-port",
        "port_specification": "USE_NAMED_PORT",
        "grpc_service_name": "testservice",
    })
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewHealthCheck(ctx, "grpc-health-check", &compute.HealthCheckArgs{
			Name:             pulumi.String("grpc-health-check"),
			TimeoutSec:       pulumi.Int(1),
			CheckIntervalSec: pulumi.Int(1),
			GrpcHealthCheck: &compute.HealthCheckGrpcHealthCheckArgs{
				PortName:          pulumi.String("health-check-port"),
				PortSpecification: pulumi.String("USE_NAMED_PORT"),
				GrpcServiceName:   pulumi.String("testservice"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var grpc_health_check = new Gcp.Compute.HealthCheck("grpc-health-check", new()
    {
        Name = "grpc-health-check",
        TimeoutSec = 1,
        CheckIntervalSec = 1,
        GrpcHealthCheck = new Gcp.Compute.Inputs.HealthCheckGrpcHealthCheckArgs
        {
            PortName = "health-check-port",
            PortSpecification = "USE_NAMED_PORT",
            GrpcServiceName = "testservice",
        },
    });

});
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()
            .name("grpc-health-check")
            .timeoutSec(1)
            .checkIntervalSec(1)
            .grpcHealthCheck(HealthCheckGrpcHealthCheckArgs.builder()
                .portName("health-check-port")
                .portSpecification("USE_NAMED_PORT")
                .grpcServiceName("testservice")
                .build())
            .build());

    }
}
resources:
  grpc-health-check:
    type: gcp:compute:HealthCheck
    properties:
      name: grpc-health-check
      timeoutSec: 1
      checkIntervalSec: 1
      grpcHealthCheck:
        portName: health-check-port
        portSpecification: USE_NAMED_PORT
        grpcServiceName: testservice

The grpcServiceName property specifies which service to check when multiple services share a port. The portSpecification set to USE_NAMED_PORT allows the check to reference a named port from the instance group configuration.

Enable health check logging for diagnostics

Debugging connectivity issues or understanding health check behavior requires visibility into probe results.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const health_check_with_logging = new gcp.compute.HealthCheck("health-check-with-logging", {
    name: "tcp-health-check",
    timeoutSec: 1,
    checkIntervalSec: 1,
    tcpHealthCheck: {
        port: 22,
    },
    logConfig: {
        enable: true,
    },
});
import pulumi
import pulumi_gcp as gcp

health_check_with_logging = gcp.compute.HealthCheck("health-check-with-logging",
    name="tcp-health-check",
    timeout_sec=1,
    check_interval_sec=1,
    tcp_health_check={
        "port": 22,
    },
    log_config={
        "enable": True,
    })
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewHealthCheck(ctx, "health-check-with-logging", &compute.HealthCheckArgs{
			Name:             pulumi.String("tcp-health-check"),
			TimeoutSec:       pulumi.Int(1),
			CheckIntervalSec: pulumi.Int(1),
			TcpHealthCheck: &compute.HealthCheckTcpHealthCheckArgs{
				Port: pulumi.Int(22),
			},
			LogConfig: &compute.HealthCheckLogConfigArgs{
				Enable: pulumi.Bool(true),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var health_check_with_logging = new Gcp.Compute.HealthCheck("health-check-with-logging", new()
    {
        Name = "tcp-health-check",
        TimeoutSec = 1,
        CheckIntervalSec = 1,
        TcpHealthCheck = new Gcp.Compute.Inputs.HealthCheckTcpHealthCheckArgs
        {
            Port = 22,
        },
        LogConfig = new Gcp.Compute.Inputs.HealthCheckLogConfigArgs
        {
            Enable = true,
        },
    });

});
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 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()
            .name("tcp-health-check")
            .timeoutSec(1)
            .checkIntervalSec(1)
            .tcpHealthCheck(HealthCheckTcpHealthCheckArgs.builder()
                .port(22)
                .build())
            .logConfig(HealthCheckLogConfigArgs.builder()
                .enable(true)
                .build())
            .build());

    }
}
resources:
  health-check-with-logging:
    type: gcp:compute:HealthCheck
    properties:
      name: tcp-health-check
      timeoutSec: 1
      checkIntervalSec: 1
      tcpHealthCheck:
        port: '22'
      logConfig:
        enable: true

The logConfig property with enable set to true records health check probe results. These logs capture success and failure events, helping you diagnose why instances are marked unhealthy or understand probe patterns.

Restrict health checks to specific regions

Global health checks can probe from any region, but some deployments need to control which regions perform checks to reduce latency or meet compliance requirements.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const http_health_check_with_source_regions = new gcp.compute.HealthCheck("http-health-check-with-source-regions", {
    name: "http-health-check",
    checkIntervalSec: 30,
    httpHealthCheck: {
        port: 80,
        portSpecification: "USE_FIXED_PORT",
    },
    sourceRegions: [
        "us-west1",
        "us-central1",
        "us-east5",
    ],
});
import pulumi
import pulumi_gcp as gcp

http_health_check_with_source_regions = gcp.compute.HealthCheck("http-health-check-with-source-regions",
    name="http-health-check",
    check_interval_sec=30,
    http_health_check={
        "port": 80,
        "port_specification": "USE_FIXED_PORT",
    },
    source_regions=[
        "us-west1",
        "us-central1",
        "us-east5",
    ])
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewHealthCheck(ctx, "http-health-check-with-source-regions", &compute.HealthCheckArgs{
			Name:             pulumi.String("http-health-check"),
			CheckIntervalSec: pulumi.Int(30),
			HttpHealthCheck: &compute.HealthCheckHttpHealthCheckArgs{
				Port:              pulumi.Int(80),
				PortSpecification: pulumi.String("USE_FIXED_PORT"),
			},
			SourceRegions: pulumi.StringArray{
				pulumi.String("us-west1"),
				pulumi.String("us-central1"),
				pulumi.String("us-east5"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var http_health_check_with_source_regions = new Gcp.Compute.HealthCheck("http-health-check-with-source-regions", new()
    {
        Name = "http-health-check",
        CheckIntervalSec = 30,
        HttpHealthCheck = new Gcp.Compute.Inputs.HealthCheckHttpHealthCheckArgs
        {
            Port = 80,
            PortSpecification = "USE_FIXED_PORT",
        },
        SourceRegions = new[]
        {
            "us-west1",
            "us-central1",
            "us-east5",
        },
    });

});
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_with_source_regions = new HealthCheck("http-health-check-with-source-regions", HealthCheckArgs.builder()
            .name("http-health-check")
            .checkIntervalSec(30)
            .httpHealthCheck(HealthCheckHttpHealthCheckArgs.builder()
                .port(80)
                .portSpecification("USE_FIXED_PORT")
                .build())
            .sourceRegions(            
                "us-west1",
                "us-central1",
                "us-east5")
            .build());

    }
}
resources:
  http-health-check-with-source-regions:
    type: gcp:compute:HealthCheck
    properties:
      name: http-health-check
      checkIntervalSec: 30
      httpHealthCheck:
        port: 80
        portSpecification: USE_FIXED_PORT
      sourceRegions:
        - us-west1
        - us-central1
        - us-east5

The sourceRegions property limits probes to exactly three specified regions. When set, checkIntervalSec must be at least 30 seconds, and certain protocols (SSL, HTTP2, GRPC) and features (proxy headers, TCP request field) are not supported. Health checks with sourceRegions cannot be used with BackendService or managed instance group auto-healing.

Beyond these examples

These snippets focus on specific health check features: HTTP, HTTPS, TCP, and gRPC protocol checks, response validation and custom health endpoints, and logging and regional probe control. They’re intentionally minimal rather than full load balancing configurations.

The examples may reference pre-existing infrastructure such as backend instances or services to monitor, and named ports configured on instance groups for USE_NAMED_PORT. They focus on configuring the health check rather than provisioning the complete load balancing stack.

To keep things focused, common health check patterns are omitted, including:

  • SSL health checks (similar to TCP/HTTPS patterns)
  • HTTP/2 health checks (similar to HTTP/HTTPS patterns)
  • gRPC with TLS (similar to gRPC without TLS)
  • Proxy header configuration (proxyHeader property)
  • Integration with backend services and load balancers

These omissions are intentional: the goal is to illustrate how each health check feature is wired, not provide drop-in load balancing modules. See the Compute HealthCheck resource reference for all available configuration options.

Let's configure GCP Compute Health Checks

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Health Check Types & Selection
When should I use legacy HTTP(S) health checks instead of this resource?
Legacy HTTP(S) health checks must be used for target pool-based network load balancers. See the official guide for choosing the appropriate health check type.
What health check protocols are supported?
The resource supports TCP, SSL, HTTP, HTTPS, HTTP/2, gRPC, and gRPC with TLS. Configure the appropriate health check block (tcpHealthCheck, httpHealthCheck, etc.) for your protocol.
Timing & Thresholds
Why am I getting an error about timeoutSec and checkIntervalSec?
The timeoutSec value cannot be greater than checkIntervalSec. Ensure your timeout is less than or equal to your check interval.
What are the default timing and threshold values?
Health checks default to 5-second intervals (checkIntervalSec) with 5-second timeouts (timeoutSec). Instances are marked healthy after 2 consecutive successes (healthyThreshold) and unhealthy after 2 consecutive failures (unhealthyThreshold).
Source Regions & Restrictions
What are the restrictions when using sourceRegions?

When configuring sourceRegions, you must specify exactly 3 regions and accept these restrictions:

  • SSL, HTTP/2, and gRPC protocols are not supported
  • The TCP request field is not supported
  • The proxyHeader field for HTTP, HTTPS, and TCP is not supported
  • checkIntervalSec must be at least 30 seconds
  • Cannot be used with BackendService or managed instance group auto-healing
Can I use sourceRegions with any health check protocol?
No, sourceRegions only supports HTTP, HTTPS, and TCP protocols. SSL, HTTP/2, and gRPC are not supported when source regions are configured.
Configuration & Naming
Can I change the health check name after creation?
No, the name property is immutable. The name must be 1-63 characters long, start with a lowercase letter, and contain only lowercase letters, digits, and dashes (except the last character cannot be a dash).
How do I enable logging for health checks?
Configure the logConfig block with enable set to true.
How do I use named ports instead of fixed port numbers?
Set portSpecification to USE_NAMED_PORT and specify the portName in your health check configuration block.

Using a different cloud?

Explore networking guides for other cloud providers: