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

LoadBalancer

Provides a Hetzner Cloud Load Balancer to represent a Load Balancer in the Hetzner Cloud.

Example Usage

using Pulumi;
using HCloud = Pulumi.HCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var myserver = new HCloud.Server("myserver", new HCloud.ServerArgs
        {
            ServerType = "cx11",
            Image = "ubuntu-18.04",
        });
        var loadBalancer = new HCloud.LoadBalancer("loadBalancer", new HCloud.LoadBalancerArgs
        {
            LoadBalancerType = "lb11",
            Location = "nbg1",
            Targets = 
            {
                new HCloud.Inputs.LoadBalancerTargetArgs
                {
                    Type = "server",
                    ServerId = myserver.Id,
                },
            },
        });
    }

}
package main

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

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        myserver, err := hcloud.NewServer(ctx, "myserver", &hcloud.ServerArgs{
            ServerType: pulumi.String("cx11"),
            Image:      pulumi.String("ubuntu-18.04"),
        })
        if err != nil {
            return err
        }
        _, err = hcloud.NewLoadBalancer(ctx, "loadBalancer", &hcloud.LoadBalancerArgs{
            LoadBalancerType: pulumi.String("lb11"),
            Location:         pulumi.String("nbg1"),
            Targets: hcloud.LoadBalancerTargetArray{
                &hcloud.LoadBalancerTargetArgs{
                    Type:     pulumi.String("server"),
                    ServerId: myserver.ID(),
                },
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_hcloud as hcloud

myserver = hcloud.Server("myserver",
    server_type="cx11",
    image="ubuntu-18.04")
load_balancer = hcloud.LoadBalancer("loadBalancer",
    load_balancer_type="lb11",
    location="nbg1",
    targets=[hcloud.LoadBalancerTargetArgs(
        type="server",
        server_id=myserver.id,
    )])
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const myserver = new hcloud.Server("myserver", {
    serverType: "cx11",
    image: "ubuntu-18.04",
});
const loadBalancer = new hcloud.LoadBalancer("loadBalancer", {
    loadBalancerType: "lb11",
    location: "nbg1",
    targets: [{
        type: "server",
        serverId: myserver.id,
    }],
});

Create a LoadBalancer Resource

new LoadBalancer(name: string, args: LoadBalancerArgs, opts?: CustomResourceOptions);
def LoadBalancer(resource_name: str, opts: Optional[ResourceOptions] = None, algorithm: Optional[LoadBalancerAlgorithmArgs] = None, labels: Optional[Mapping[str, Any]] = None, load_balancer_type: Optional[str] = None, location: Optional[str] = None, name: Optional[str] = None, network_zone: Optional[str] = None, targets: Optional[Sequence[LoadBalancerTargetArgs]] = None)
func NewLoadBalancer(ctx *Context, name string, args LoadBalancerArgs, opts ...ResourceOption) (*LoadBalancer, error)
public LoadBalancer(string name, LoadBalancerArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args LoadBalancerArgs
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 LoadBalancerArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args LoadBalancerArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

LoadBalancer Resource Properties

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

Inputs

The LoadBalancer resource accepts the following input properties:

LoadBalancerType string

Type of the Load Balancer.

Algorithm Pulumi.HCloud.Inputs.LoadBalancerAlgorithmArgs

Configuration of the algorithm the Load Balancer use.

Labels Dictionary<string, object>

User-defined labels (key-value pairs) should be created with.

Location string

Location of the Load Balancer. Require when no network_zone is set.

Name string

Name of the Load Balancer.

NetworkZone string

Network Zone of the Load Balancer. Require when no location is set.

Targets List<Pulumi.HCloud.Inputs.LoadBalancerTargetArgs>

List of targets of the Load Balancer.

LoadBalancerType string

Type of the Load Balancer.

Algorithm LoadBalancerAlgorithm

Configuration of the algorithm the Load Balancer use.

Labels map[string]interface{}

User-defined labels (key-value pairs) should be created with.

Location string

Location of the Load Balancer. Require when no network_zone is set.

Name string

Name of the Load Balancer.

NetworkZone string

Network Zone of the Load Balancer. Require when no location is set.

Targets []LoadBalancerTargetType

List of targets of the Load Balancer.

loadBalancerType string

Type of the Load Balancer.

algorithm LoadBalancerAlgorithm

Configuration of the algorithm the Load Balancer use.

labels {[key: string]: any}

User-defined labels (key-value pairs) should be created with.

location string

Location of the Load Balancer. Require when no network_zone is set.

name string

Name of the Load Balancer.

networkZone string

Network Zone of the Load Balancer. Require when no location is set.

targets LoadBalancerTarget[]

List of targets of the Load Balancer.

load_balancer_type str

Type of the Load Balancer.

algorithm LoadBalancerAlgorithmArgs

Configuration of the algorithm the Load Balancer use.

labels Mapping[str, Any]

User-defined labels (key-value pairs) should be created with.

location str

Location of the Load Balancer. Require when no network_zone is set.

name str

Name of the Load Balancer.

network_zone str

Network Zone of the Load Balancer. Require when no location is set.

targets Sequence[LoadBalancerTargetArgs]

List of targets of the Load Balancer.

Outputs

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

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

(string) IPv4 Address of the Load Balancer.

Ipv6 string

(string) IPv4 Address of the Load Balancer.

NetworkId int
NetworkIp string
Id string
The provider-assigned unique ID for this managed resource.
Ipv4 string

(string) IPv4 Address of the Load Balancer.

Ipv6 string

(string) IPv4 Address of the Load Balancer.

NetworkId int
NetworkIp string
id string
The provider-assigned unique ID for this managed resource.
ipv4 string

(string) IPv4 Address of the Load Balancer.

ipv6 string

(string) IPv4 Address of the Load Balancer.

networkId number
networkIp string
id str
The provider-assigned unique ID for this managed resource.
ipv4 str

(string) IPv4 Address of the Load Balancer.

ipv6 str

(string) IPv4 Address of the Load Balancer.

network_id int
network_ip str

Look up an Existing LoadBalancer Resource

Get an existing LoadBalancer 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?: LoadBalancerState, opts?: CustomResourceOptions): LoadBalancer
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, algorithm: Optional[LoadBalancerAlgorithmArgs] = None, ipv4: Optional[str] = None, ipv6: Optional[str] = None, labels: Optional[Mapping[str, Any]] = None, load_balancer_type: Optional[str] = None, location: Optional[str] = None, name: Optional[str] = None, network_id: Optional[int] = None, network_ip: Optional[str] = None, network_zone: Optional[str] = None, targets: Optional[Sequence[LoadBalancerTargetArgs]] = None) -> LoadBalancer
func GetLoadBalancer(ctx *Context, name string, id IDInput, state *LoadBalancerState, opts ...ResourceOption) (*LoadBalancer, error)
public static LoadBalancer Get(string name, Input<string> id, LoadBalancerState? 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:

Algorithm Pulumi.HCloud.Inputs.LoadBalancerAlgorithmArgs

Configuration of the algorithm the Load Balancer use.

Ipv4 string

(string) IPv4 Address of the Load Balancer.

Ipv6 string

(string) IPv4 Address of the Load Balancer.

Labels Dictionary<string, object>

User-defined labels (key-value pairs) should be created with.

LoadBalancerType string

Type of the Load Balancer.

Location string

Location of the Load Balancer. Require when no network_zone is set.

Name string

Name of the Load Balancer.

NetworkId int
NetworkIp string
NetworkZone string

Network Zone of the Load Balancer. Require when no location is set.

Targets List<Pulumi.HCloud.Inputs.LoadBalancerTargetArgs>

List of targets of the Load Balancer.

Algorithm LoadBalancerAlgorithm

Configuration of the algorithm the Load Balancer use.

Ipv4 string

(string) IPv4 Address of the Load Balancer.

Ipv6 string

(string) IPv4 Address of the Load Balancer.

Labels map[string]interface{}

User-defined labels (key-value pairs) should be created with.

LoadBalancerType string

Type of the Load Balancer.

Location string

Location of the Load Balancer. Require when no network_zone is set.

Name string

Name of the Load Balancer.

NetworkId int
NetworkIp string
NetworkZone string

Network Zone of the Load Balancer. Require when no location is set.

Targets []LoadBalancerTargetType

List of targets of the Load Balancer.

algorithm LoadBalancerAlgorithm

Configuration of the algorithm the Load Balancer use.

ipv4 string

(string) IPv4 Address of the Load Balancer.

ipv6 string

(string) IPv4 Address of the Load Balancer.

labels {[key: string]: any}

User-defined labels (key-value pairs) should be created with.

loadBalancerType string

Type of the Load Balancer.

location string

Location of the Load Balancer. Require when no network_zone is set.

name string

Name of the Load Balancer.

networkId number
networkIp string
networkZone string

Network Zone of the Load Balancer. Require when no location is set.

targets LoadBalancerTarget[]

List of targets of the Load Balancer.

algorithm LoadBalancerAlgorithmArgs

Configuration of the algorithm the Load Balancer use.

ipv4 str

(string) IPv4 Address of the Load Balancer.

ipv6 str

(string) IPv4 Address of the Load Balancer.

labels Mapping[str, Any]

User-defined labels (key-value pairs) should be created with.

load_balancer_type str

Type of the Load Balancer.

location str

Location of the Load Balancer. Require when no network_zone is set.

name str

Name of the Load Balancer.

network_id int
network_ip str
network_zone str

Network Zone of the Load Balancer. Require when no location is set.

targets Sequence[LoadBalancerTargetArgs]

List of targets of the Load Balancer.

Supporting Types

LoadBalancerAlgorithm

Type string

Type of the Load Balancer Algorithm. round_robin or least_connections

Type string

Type of the Load Balancer Algorithm. round_robin or least_connections

type string

Type of the Load Balancer Algorithm. round_robin or least_connections

type str

Type of the Load Balancer Algorithm. round_robin or least_connections

LoadBalancerTarget

Type string

Type of the target. server

ServerId int

ID of the server which should be a target for this Load Balancer. Required if type is server

UsePrivateIp bool

Deprecated: Does not work. Use the hcloud_load_balancer_target resource instead.

Type string

Type of the target. server

ServerId int

ID of the server which should be a target for this Load Balancer. Required if type is server

UsePrivateIp bool

Deprecated: Does not work. Use the hcloud_load_balancer_target resource instead.

type string

Type of the target. server

serverId number

ID of the server which should be a target for this Load Balancer. Required if type is server

usePrivateIp boolean

Deprecated: Does not work. Use the hcloud_load_balancer_target resource instead.

type str

Type of the target. server

server_id int

ID of the server which should be a target for this Load Balancer. Required if type is server

use_private_ip bool

Deprecated: Does not work. Use the hcloud_load_balancer_target resource instead.

Import

Load Balancers can be imported using its id

 $ pulumi import hcloud:index/loadBalancer:LoadBalancer my_load_balancer <id>

Package Details

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