Healthcheck Args
Standalone Health Checks provide a way to monitor origin servers without needing a Cloudflare Load Balancer.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";
// HTTPS Healthcheck
const httpHealthCheck = new cloudflare.Healthcheck("http_health_check", {
zoneId: cloudflareZoneId,
name: "http-health-check",
description: "example http health check",
address: "example.com",
suspended: false,
checkRegions: [
"WEU",
"EEU",
],
type: "HTTPS",
port: 443,
method: "GET",
path: "/health",
expectedBody: "alive",
expectedCodes: [
"2xx",
"301",
],
followRedirects: true,
allowInsecure: false,
headers: [{
header: "Host",
values: ["example.com"],
}],
timeout: 10,
retries: 2,
interval: 60,
consecutiveFails: 3,
consecutiveSuccesses: 2,
});
// TCP Healthcheck
const tcpHealthCheck = new cloudflare.Healthcheck("tcp_health_check", {
zoneId: cloudflareZoneId,
name: "tcp-health-check",
description: "example tcp health check",
address: "example.com",
suspended: false,
checkRegions: [
"WEU",
"EEU",
],
type: "TCP",
port: 22,
method: "connection_established",
timeout: 10,
retries: 2,
interval: 60,
consecutiveFails: 3,
consecutiveSuccesses: 2,
});
import pulumi
import pulumi_cloudflare as cloudflare
# HTTPS Healthcheck
http_health_check = cloudflare.Healthcheck("http_health_check",
zone_id=cloudflare_zone_id,
name="http-health-check",
description="example http health check",
address="example.com",
suspended=False,
check_regions=[
"WEU",
"EEU",
],
type="HTTPS",
port=443,
method="GET",
path="/health",
expected_body="alive",
expected_codes=[
"2xx",
"301",
],
follow_redirects=True,
allow_insecure=False,
headers=[{
"header": "Host",
"values": ["example.com"],
}],
timeout=10,
retries=2,
interval=60,
consecutive_fails=3,
consecutive_successes=2)
# TCP Healthcheck
tcp_health_check = cloudflare.Healthcheck("tcp_health_check",
zone_id=cloudflare_zone_id,
name="tcp-health-check",
description="example tcp health check",
address="example.com",
suspended=False,
check_regions=[
"WEU",
"EEU",
],
type="TCP",
port=22,
method="connection_established",
timeout=10,
retries=2,
interval=60,
consecutive_fails=3,
consecutive_successes=2)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;
return await Deployment.RunAsync(() =>
{
// HTTPS Healthcheck
var httpHealthCheck = new Cloudflare.Healthcheck("http_health_check", new()
{
ZoneId = cloudflareZoneId,
Name = "http-health-check",
Description = "example http health check",
Address = "example.com",
Suspended = false,
CheckRegions = new[]
{
"WEU",
"EEU",
},
Type = "HTTPS",
Port = 443,
Method = "GET",
Path = "/health",
ExpectedBody = "alive",
ExpectedCodes = new[]
{
"2xx",
"301",
},
FollowRedirects = true,
AllowInsecure = false,
Headers = new[]
{
new Cloudflare.Inputs.HealthcheckHeaderArgs
{
Header = "Host",
Values = new[]
{
"example.com",
},
},
},
Timeout = 10,
Retries = 2,
Interval = 60,
ConsecutiveFails = 3,
ConsecutiveSuccesses = 2,
});
// TCP Healthcheck
var tcpHealthCheck = new Cloudflare.Healthcheck("tcp_health_check", new()
{
ZoneId = cloudflareZoneId,
Name = "tcp-health-check",
Description = "example tcp health check",
Address = "example.com",
Suspended = false,
CheckRegions = new[]
{
"WEU",
"EEU",
},
Type = "TCP",
Port = 22,
Method = "connection_established",
Timeout = 10,
Retries = 2,
Interval = 60,
ConsecutiveFails = 3,
ConsecutiveSuccesses = 2,
});
});
package main
import (
"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// HTTPS Healthcheck
_, err := cloudflare.NewHealthcheck(ctx, "http_health_check", &cloudflare.HealthcheckArgs{
ZoneId: pulumi.Any(cloudflareZoneId),
Name: pulumi.String("http-health-check"),
Description: pulumi.String("example http health check"),
Address: pulumi.String("example.com"),
Suspended: pulumi.Bool(false),
CheckRegions: pulumi.StringArray{
pulumi.String("WEU"),
pulumi.String("EEU"),
},
Type: pulumi.String("HTTPS"),
Port: pulumi.Int(443),
Method: pulumi.String("GET"),
Path: pulumi.String("/health"),
ExpectedBody: pulumi.String("alive"),
ExpectedCodes: pulumi.StringArray{
pulumi.String("2xx"),
pulumi.String("301"),
},
FollowRedirects: pulumi.Bool(true),
AllowInsecure: pulumi.Bool(false),
Headers: cloudflare.HealthcheckHeaderArray{
&cloudflare.HealthcheckHeaderArgs{
Header: pulumi.String("Host"),
Values: pulumi.StringArray{
pulumi.String("example.com"),
},
},
},
Timeout: pulumi.Int(10),
Retries: pulumi.Int(2),
Interval: pulumi.Int(60),
ConsecutiveFails: pulumi.Int(3),
ConsecutiveSuccesses: pulumi.Int(2),
})
if err != nil {
return err
}
// TCP Healthcheck
_, err = cloudflare.NewHealthcheck(ctx, "tcp_health_check", &cloudflare.HealthcheckArgs{
ZoneId: pulumi.Any(cloudflareZoneId),
Name: pulumi.String("tcp-health-check"),
Description: pulumi.String("example tcp health check"),
Address: pulumi.String("example.com"),
Suspended: pulumi.Bool(false),
CheckRegions: pulumi.StringArray{
pulumi.String("WEU"),
pulumi.String("EEU"),
},
Type: pulumi.String("TCP"),
Port: pulumi.Int(22),
Method: pulumi.String("connection_established"),
Timeout: pulumi.Int(10),
Retries: pulumi.Int(2),
Interval: pulumi.Int(60),
ConsecutiveFails: pulumi.Int(3),
ConsecutiveSuccesses: pulumi.Int(2),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cloudflare.Healthcheck;
import com.pulumi.cloudflare.HealthcheckArgs;
import com.pulumi.cloudflare.inputs.HealthcheckHeaderArgs;
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) {
// HTTPS Healthcheck
var httpHealthCheck = new Healthcheck("httpHealthCheck", HealthcheckArgs.builder()
.zoneId(cloudflareZoneId)
.name("http-health-check")
.description("example http health check")
.address("example.com")
.suspended(false)
.checkRegions(
"WEU",
"EEU")
.type("HTTPS")
.port(443)
.method("GET")
.path("/health")
.expectedBody("alive")
.expectedCodes(
"2xx",
"301")
.followRedirects(true)
.allowInsecure(false)
.headers(HealthcheckHeaderArgs.builder()
.header("Host")
.values("example.com")
.build())
.timeout(10)
.retries(2)
.interval(60)
.consecutiveFails(3)
.consecutiveSuccesses(2)
.build());
// TCP Healthcheck
var tcpHealthCheck = new Healthcheck("tcpHealthCheck", HealthcheckArgs.builder()
.zoneId(cloudflareZoneId)
.name("tcp-health-check")
.description("example tcp health check")
.address("example.com")
.suspended(false)
.checkRegions(
"WEU",
"EEU")
.type("TCP")
.port(22)
.method("connection_established")
.timeout(10)
.retries(2)
.interval(60)
.consecutiveFails(3)
.consecutiveSuccesses(2)
.build());
}
}
resources:
# HTTPS Healthcheck
httpHealthCheck:
type: cloudflare:Healthcheck
name: http_health_check
properties:
zoneId: ${cloudflareZoneId}
name: http-health-check
description: example http health check
address: example.com
suspended: false
checkRegions:
- WEU
- EEU
type: HTTPS
port: 443
method: GET
path: /health
expectedBody: alive
expectedCodes:
- 2xx
- '301'
followRedirects: true
allowInsecure: false
headers:
- header: Host
values:
- example.com
timeout: 10
retries: 2
interval: 60
consecutiveFails: 3
consecutiveSuccesses: 2
# TCP Healthcheck
tcpHealthCheck:
type: cloudflare:Healthcheck
name: tcp_health_check
properties:
zoneId: ${cloudflareZoneId}
name: tcp-health-check
description: example tcp health check
address: example.com
suspended: false
checkRegions:
- WEU
- EEU
type: TCP
port: 22
method: connection_established
timeout: 10
retries: 2
interval: 60
consecutiveFails: 3
consecutiveSuccesses: 2
Import
Use the Zone ID and Healthcheck ID to import.
$ pulumi import cloudflare:index/healthcheck:Healthcheck example <zone_id>/<healthcheck_id>
Constructors
Properties
Do not validate the certificate when the health check uses HTTPS. Defaults to false
.
A list of regions from which to run health checks. If not set, Cloudflare will pick a default region. Available values: WNAM
, ENAM
, WEU
, EEU
, NSAM
, SSAM
, OC
, ME
, NAF
, SAF
, IN
, SEAS
, NEAS
, ALL_REGIONS
.
The number of consecutive fails required from a health check before changing the health to unhealthy. Defaults to 1
.
The number of consecutive successes required from a health check before changing the health to healthy. Defaults to 1
.
A human-readable description of the health check.
A case-insensitive sub-string to look for in the response body. If this string is not found the origin will be marked as unhealthy.
The expected HTTP response codes (e.g. '200') or code ranges (e.g. '2xx' for all codes starting with 2) of the health check.
Follow redirects if the origin returns a 3xx status code. Defaults to false
.
The HTTP request headers to send in the health check. It is recommended you set a Host header by default. The User-Agent header cannot be overridden.