Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

LoadBalancerMonitor

If you’re using Cloudflare’s Load Balancing to load-balance across multiple origin servers or data centers, you configure one of these Monitors to actively check the availability of those servers over HTTP(S) or TCP.

Note: When creating a monitor, you have to pass account_id to the provider configuration in order to create account level resources. Otherwise, by default, it will be a user level resource.

Example Usage

HTTP Monitor

using Pulumi;
using Cloudflare = Pulumi.Cloudflare;

class MyStack : Stack
{
    public MyStack()
    {
        var httpMonitor = new Cloudflare.LoadBalancerMonitor("httpMonitor", new Cloudflare.LoadBalancerMonitorArgs
        {
            AllowInsecure = false,
            Description = "example http load balancer",
            ExpectedBody = "alive",
            ExpectedCodes = "2xx",
            FollowRedirects = true,
            Headers = 
            {
                new Cloudflare.Inputs.LoadBalancerMonitorHeaderArgs
                {
                    Header = "Host",
                    Values = 
                    {
                        "example.com",
                    },
                },
            },
            Interval = 60,
            Method = "GET",
            Path = "/health",
            ProbeZone = "example.com",
            Retries = 5,
            Timeout = 7,
            Type = "http",
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-cloudflare/sdk/v2/go/cloudflare"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := cloudflare.NewLoadBalancerMonitor(ctx, "httpMonitor", &cloudflare.LoadBalancerMonitorArgs{
            AllowInsecure:   pulumi.Bool(false),
            Description:     pulumi.String("example http load balancer"),
            ExpectedBody:    pulumi.String("alive"),
            ExpectedCodes:   pulumi.String("2xx"),
            FollowRedirects: pulumi.Bool(true),
            Headers: cloudflare.LoadBalancerMonitorHeaderArray{
                &cloudflare.LoadBalancerMonitorHeaderArgs{
                    Header: pulumi.String("Host"),
                    Values: pulumi.StringArray{
                        pulumi.String("example.com"),
                    },
                },
            },
            Interval:  pulumi.Int(60),
            Method:    pulumi.String("GET"),
            Path:      pulumi.String("/health"),
            ProbeZone: pulumi.String("example.com"),
            Retries:   pulumi.Int(5),
            Timeout:   pulumi.Int(7),
            Type:      pulumi.String("http"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_cloudflare as cloudflare

http_monitor = cloudflare.LoadBalancerMonitor("httpMonitor",
    allow_insecure=False,
    description="example http load balancer",
    expected_body="alive",
    expected_codes="2xx",
    follow_redirects=True,
    headers=[cloudflare.LoadBalancerMonitorHeaderArgs(
        header="Host",
        values=["example.com"],
    )],
    interval=60,
    method="GET",
    path="/health",
    probe_zone="example.com",
    retries=5,
    timeout=7,
    type="http")
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";

const httpMonitor = new cloudflare.LoadBalancerMonitor("http_monitor", {
    allowInsecure: false,
    description: "example http load balancer",
    expectedBody: "alive",
    expectedCodes: "2xx",
    followRedirects: true,
    headers: [{
        header: "Host",
        values: ["example.com"],
    }],
    interval: 60,
    method: "GET",
    path: "/health",
    probeZone: "example.com",
    retries: 5,
    timeout: 7,
    type: "http",
});

TCP Monitor

using Pulumi;
using Cloudflare = Pulumi.Cloudflare;

class MyStack : Stack
{
    public MyStack()
    {
        var tcpMonitor = new Cloudflare.LoadBalancerMonitor("tcpMonitor", new Cloudflare.LoadBalancerMonitorArgs
        {
            Description = "example tcp load balancer",
            Interval = 60,
            Method = "connection_established",
            Port = 8080,
            Retries = 5,
            Timeout = 7,
            Type = "tcp",
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-cloudflare/sdk/v2/go/cloudflare"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := cloudflare.NewLoadBalancerMonitor(ctx, "tcpMonitor", &cloudflare.LoadBalancerMonitorArgs{
            Description: pulumi.String("example tcp load balancer"),
            Interval:    pulumi.Int(60),
            Method:      pulumi.String("connection_established"),
            Port:        pulumi.Int(8080),
            Retries:     pulumi.Int(5),
            Timeout:     pulumi.Int(7),
            Type:        pulumi.String("tcp"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_cloudflare as cloudflare

tcp_monitor = cloudflare.LoadBalancerMonitor("tcpMonitor",
    description="example tcp load balancer",
    interval=60,
    method="connection_established",
    port=8080,
    retries=5,
    timeout=7,
    type="tcp")
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";

const tcpMonitor = new cloudflare.LoadBalancerMonitor("tcp_monitor", {
    description: "example tcp load balancer",
    interval: 60,
    method: "connection_established",
    port: 8080,
    retries: 5,
    timeout: 7,
    type: "tcp",
});

Create a LoadBalancerMonitor Resource

new LoadBalancerMonitor(name: string, args?: LoadBalancerMonitorArgs, opts?: CustomResourceOptions);
def LoadBalancerMonitor(resource_name: str, opts: Optional[ResourceOptions] = None, allow_insecure: Optional[bool] = None, description: Optional[str] = None, expected_body: Optional[str] = None, expected_codes: Optional[str] = None, follow_redirects: Optional[bool] = None, headers: Optional[Sequence[LoadBalancerMonitorHeaderArgs]] = None, interval: Optional[int] = None, method: Optional[str] = None, path: Optional[str] = None, port: Optional[int] = None, probe_zone: Optional[str] = None, retries: Optional[int] = None, timeout: Optional[int] = None, type: Optional[str] = None)
func NewLoadBalancerMonitor(ctx *Context, name string, args *LoadBalancerMonitorArgs, opts ...ResourceOption) (*LoadBalancerMonitor, error)
public LoadBalancerMonitor(string name, LoadBalancerMonitorArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args LoadBalancerMonitorArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args LoadBalancerMonitorArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args LoadBalancerMonitorArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

LoadBalancerMonitor Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The LoadBalancerMonitor resource accepts the following input properties:

AllowInsecure bool

Do not validate the certificate when monitor use HTTPS. Only valid if type is “http” or “https”.

Description string

Free text description.

ExpectedBody string

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. Only valid if type is “http” or “https”. Default: “”.

ExpectedCodes string

The expected HTTP response code or code range of the health check. Eg 2xx. Only valid and required if type is “http” or “https”.

FollowRedirects bool

Follow redirects if returned by the origin. Only valid if type is “http” or “https”.

Headers List<LoadBalancerMonitorHeaderArgs>

The header name.

Interval int

The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Default: 60.

Method string

The method to use for the health check. Valid values are any valid HTTP verb if type is “http” or “https”, or connection_established if type is “tcp”. Default: “GET” if type is “http” or “https”, or “connection_established” if type is “tcp” .

Path string

The endpoint path to health check against. Default: “/”. Only valid if type is “http” or “https”.

Port int

The port number to use for the healthcheck, required when creating a TCP monitor. Valid values are in the range 0-65535.

ProbeZone string

Assign this monitor to emulate the specified zone while probing. Only valid if type is “http” or “https”.

Retries int

The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Default: 2.

Timeout int

The timeout (in seconds) before marking the health check as failed. Default: 5.

Type string

The protocol to use for the healthcheck. Currently supported protocols are ‘HTTP’, ‘HTTPS’ and ‘TCP’. Default: “http”.

AllowInsecure bool

Do not validate the certificate when monitor use HTTPS. Only valid if type is “http” or “https”.

Description string

Free text description.

ExpectedBody string

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. Only valid if type is “http” or “https”. Default: “”.

ExpectedCodes string

The expected HTTP response code or code range of the health check. Eg 2xx. Only valid and required if type is “http” or “https”.

FollowRedirects bool

Follow redirects if returned by the origin. Only valid if type is “http” or “https”.

Headers []LoadBalancerMonitorHeader

The header name.

Interval int

The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Default: 60.

Method string

The method to use for the health check. Valid values are any valid HTTP verb if type is “http” or “https”, or connection_established if type is “tcp”. Default: “GET” if type is “http” or “https”, or “connection_established” if type is “tcp” .

Path string

The endpoint path to health check against. Default: “/”. Only valid if type is “http” or “https”.

Port int

The port number to use for the healthcheck, required when creating a TCP monitor. Valid values are in the range 0-65535.

ProbeZone string

Assign this monitor to emulate the specified zone while probing. Only valid if type is “http” or “https”.

Retries int

The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Default: 2.

Timeout int

The timeout (in seconds) before marking the health check as failed. Default: 5.

Type string

The protocol to use for the healthcheck. Currently supported protocols are ‘HTTP’, ‘HTTPS’ and ‘TCP’. Default: “http”.

allowInsecure boolean

Do not validate the certificate when monitor use HTTPS. Only valid if type is “http” or “https”.

description string

Free text description.

expectedBody string

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. Only valid if type is “http” or “https”. Default: “”.

expectedCodes string

The expected HTTP response code or code range of the health check. Eg 2xx. Only valid and required if type is “http” or “https”.

followRedirects boolean

Follow redirects if returned by the origin. Only valid if type is “http” or “https”.

headers LoadBalancerMonitorHeader[]

The header name.

interval number

The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Default: 60.

method string

The method to use for the health check. Valid values are any valid HTTP verb if type is “http” or “https”, or connection_established if type is “tcp”. Default: “GET” if type is “http” or “https”, or “connection_established” if type is “tcp” .

path string

The endpoint path to health check against. Default: “/”. Only valid if type is “http” or “https”.

port number

The port number to use for the healthcheck, required when creating a TCP monitor. Valid values are in the range 0-65535.

probeZone string

Assign this monitor to emulate the specified zone while probing. Only valid if type is “http” or “https”.

retries number

The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Default: 2.

timeout number

The timeout (in seconds) before marking the health check as failed. Default: 5.

type string

The protocol to use for the healthcheck. Currently supported protocols are ‘HTTP’, ‘HTTPS’ and ‘TCP’. Default: “http”.

allow_insecure bool

Do not validate the certificate when monitor use HTTPS. Only valid if type is “http” or “https”.

description str

Free text description.

expected_body str

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. Only valid if type is “http” or “https”. Default: “”.

expected_codes str

The expected HTTP response code or code range of the health check. Eg 2xx. Only valid and required if type is “http” or “https”.

follow_redirects bool

Follow redirects if returned by the origin. Only valid if type is “http” or “https”.

headers Sequence[LoadBalancerMonitorHeaderArgs]

The header name.

interval int

The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Default: 60.

method str

The method to use for the health check. Valid values are any valid HTTP verb if type is “http” or “https”, or connection_established if type is “tcp”. Default: “GET” if type is “http” or “https”, or “connection_established” if type is “tcp” .

path str

The endpoint path to health check against. Default: “/”. Only valid if type is “http” or “https”.

port int

The port number to use for the healthcheck, required when creating a TCP monitor. Valid values are in the range 0-65535.

probe_zone str

Assign this monitor to emulate the specified zone while probing. Only valid if type is “http” or “https”.

retries int

The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Default: 2.

timeout int

The timeout (in seconds) before marking the health check as failed. Default: 5.

type str

The protocol to use for the healthcheck. Currently supported protocols are ‘HTTP’, ‘HTTPS’ and ‘TCP’. Default: “http”.

Outputs

All input properties are implicitly available as output properties. Additionally, the LoadBalancerMonitor resource produces the following output properties:

CreatedOn string

The RFC3339 timestamp of when the load balancer monitor was created.

Id string
The provider-assigned unique ID for this managed resource.
ModifiedOn string

The RFC3339 timestamp of when the load balancer monitor was last modified.

CreatedOn string

The RFC3339 timestamp of when the load balancer monitor was created.

Id string
The provider-assigned unique ID for this managed resource.
ModifiedOn string

The RFC3339 timestamp of when the load balancer monitor was last modified.

createdOn string

The RFC3339 timestamp of when the load balancer monitor was created.

id string
The provider-assigned unique ID for this managed resource.
modifiedOn string

The RFC3339 timestamp of when the load balancer monitor was last modified.

created_on str

The RFC3339 timestamp of when the load balancer monitor was created.

id str
The provider-assigned unique ID for this managed resource.
modified_on str

The RFC3339 timestamp of when the load balancer monitor was last modified.

Look up an Existing LoadBalancerMonitor Resource

Get an existing LoadBalancerMonitor resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: LoadBalancerMonitorState, opts?: CustomResourceOptions): LoadBalancerMonitor
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, allow_insecure: Optional[bool] = None, created_on: Optional[str] = None, description: Optional[str] = None, expected_body: Optional[str] = None, expected_codes: Optional[str] = None, follow_redirects: Optional[bool] = None, headers: Optional[Sequence[LoadBalancerMonitorHeaderArgs]] = None, interval: Optional[int] = None, method: Optional[str] = None, modified_on: Optional[str] = None, path: Optional[str] = None, port: Optional[int] = None, probe_zone: Optional[str] = None, retries: Optional[int] = None, timeout: Optional[int] = None, type: Optional[str] = None) -> LoadBalancerMonitor
func GetLoadBalancerMonitor(ctx *Context, name string, id IDInput, state *LoadBalancerMonitorState, opts ...ResourceOption) (*LoadBalancerMonitor, error)
public static LoadBalancerMonitor Get(string name, Input<string> id, LoadBalancerMonitorState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

AllowInsecure bool

Do not validate the certificate when monitor use HTTPS. Only valid if type is “http” or “https”.

CreatedOn string

The RFC3339 timestamp of when the load balancer monitor was created.

Description string

Free text description.

ExpectedBody string

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. Only valid if type is “http” or “https”. Default: “”.

ExpectedCodes string

The expected HTTP response code or code range of the health check. Eg 2xx. Only valid and required if type is “http” or “https”.

FollowRedirects bool

Follow redirects if returned by the origin. Only valid if type is “http” or “https”.

Headers List<LoadBalancerMonitorHeaderArgs>

The header name.

Interval int

The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Default: 60.

Method string

The method to use for the health check. Valid values are any valid HTTP verb if type is “http” or “https”, or connection_established if type is “tcp”. Default: “GET” if type is “http” or “https”, or “connection_established” if type is “tcp” .

ModifiedOn string

The RFC3339 timestamp of when the load balancer monitor was last modified.

Path string

The endpoint path to health check against. Default: “/”. Only valid if type is “http” or “https”.

Port int

The port number to use for the healthcheck, required when creating a TCP monitor. Valid values are in the range 0-65535.

ProbeZone string

Assign this monitor to emulate the specified zone while probing. Only valid if type is “http” or “https”.

Retries int

The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Default: 2.

Timeout int

The timeout (in seconds) before marking the health check as failed. Default: 5.

Type string

The protocol to use for the healthcheck. Currently supported protocols are ‘HTTP’, ‘HTTPS’ and ‘TCP’. Default: “http”.

AllowInsecure bool

Do not validate the certificate when monitor use HTTPS. Only valid if type is “http” or “https”.

CreatedOn string

The RFC3339 timestamp of when the load balancer monitor was created.

Description string

Free text description.

ExpectedBody string

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. Only valid if type is “http” or “https”. Default: “”.

ExpectedCodes string

The expected HTTP response code or code range of the health check. Eg 2xx. Only valid and required if type is “http” or “https”.

FollowRedirects bool

Follow redirects if returned by the origin. Only valid if type is “http” or “https”.

Headers []LoadBalancerMonitorHeader

The header name.

Interval int

The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Default: 60.

Method string

The method to use for the health check. Valid values are any valid HTTP verb if type is “http” or “https”, or connection_established if type is “tcp”. Default: “GET” if type is “http” or “https”, or “connection_established” if type is “tcp” .

ModifiedOn string

The RFC3339 timestamp of when the load balancer monitor was last modified.

Path string

The endpoint path to health check against. Default: “/”. Only valid if type is “http” or “https”.

Port int

The port number to use for the healthcheck, required when creating a TCP monitor. Valid values are in the range 0-65535.

ProbeZone string

Assign this monitor to emulate the specified zone while probing. Only valid if type is “http” or “https”.

Retries int

The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Default: 2.

Timeout int

The timeout (in seconds) before marking the health check as failed. Default: 5.

Type string

The protocol to use for the healthcheck. Currently supported protocols are ‘HTTP’, ‘HTTPS’ and ‘TCP’. Default: “http”.

allowInsecure boolean

Do not validate the certificate when monitor use HTTPS. Only valid if type is “http” or “https”.

createdOn string

The RFC3339 timestamp of when the load balancer monitor was created.

description string

Free text description.

expectedBody string

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. Only valid if type is “http” or “https”. Default: “”.

expectedCodes string

The expected HTTP response code or code range of the health check. Eg 2xx. Only valid and required if type is “http” or “https”.

followRedirects boolean

Follow redirects if returned by the origin. Only valid if type is “http” or “https”.

headers LoadBalancerMonitorHeader[]

The header name.

interval number

The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Default: 60.

method string

The method to use for the health check. Valid values are any valid HTTP verb if type is “http” or “https”, or connection_established if type is “tcp”. Default: “GET” if type is “http” or “https”, or “connection_established” if type is “tcp” .

modifiedOn string

The RFC3339 timestamp of when the load balancer monitor was last modified.

path string

The endpoint path to health check against. Default: “/”. Only valid if type is “http” or “https”.

port number

The port number to use for the healthcheck, required when creating a TCP monitor. Valid values are in the range 0-65535.

probeZone string

Assign this monitor to emulate the specified zone while probing. Only valid if type is “http” or “https”.

retries number

The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Default: 2.

timeout number

The timeout (in seconds) before marking the health check as failed. Default: 5.

type string

The protocol to use for the healthcheck. Currently supported protocols are ‘HTTP’, ‘HTTPS’ and ‘TCP’. Default: “http”.

allow_insecure bool

Do not validate the certificate when monitor use HTTPS. Only valid if type is “http” or “https”.

created_on str

The RFC3339 timestamp of when the load balancer monitor was created.

description str

Free text description.

expected_body str

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. Only valid if type is “http” or “https”. Default: “”.

expected_codes str

The expected HTTP response code or code range of the health check. Eg 2xx. Only valid and required if type is “http” or “https”.

follow_redirects bool

Follow redirects if returned by the origin. Only valid if type is “http” or “https”.

headers Sequence[LoadBalancerMonitorHeaderArgs]

The header name.

interval int

The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Default: 60.

method str

The method to use for the health check. Valid values are any valid HTTP verb if type is “http” or “https”, or connection_established if type is “tcp”. Default: “GET” if type is “http” or “https”, or “connection_established” if type is “tcp” .

modified_on str

The RFC3339 timestamp of when the load balancer monitor was last modified.

path str

The endpoint path to health check against. Default: “/”. Only valid if type is “http” or “https”.

port int

The port number to use for the healthcheck, required when creating a TCP monitor. Valid values are in the range 0-65535.

probe_zone str

Assign this monitor to emulate the specified zone while probing. Only valid if type is “http” or “https”.

retries int

The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Default: 2.

timeout int

The timeout (in seconds) before marking the health check as failed. Default: 5.

type str

The protocol to use for the healthcheck. Currently supported protocols are ‘HTTP’, ‘HTTPS’ and ‘TCP’. Default: “http”.

Supporting Types

LoadBalancerMonitorHeader

Header string

The header name.

Values List<string>

A list of string values for the header.

Header string

The header name.

Values []string

A list of string values for the header.

header string

The header name.

values string[]

A list of string values for the header.

header str

The header name.

values Sequence[str]

A list of string values for the header.

Package Details

Repository
https://github.com/pulumi/pulumi-cloudflare
License
Apache-2.0
Notes
This Pulumi package is based on the cloudflare Terraform Provider.