hcloud.LoadBalancer
Explore with Pulumi AI
Provides a Hetzner Cloud Load Balancer to represent a Load Balancer in the Hetzner Cloud.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;
return await Deployment.RunAsync(() =>
{
var myserver = new HCloud.Server("myserver", new()
{
ServerType = "cx11",
Image = "ubuntu-18.04",
});
var loadBalancer = new HCloud.LoadBalancer("loadBalancer", new()
{
LoadBalancerType = "lb11",
Location = "nbg1",
Targets = new[]
{
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/v3/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.LoadBalancerTargetTypeArray{
&hcloud.LoadBalancerTargetTypeArgs{
Type: pulumi.String("server"),
ServerId: myserver.ID(),
},
},
})
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.hcloud.Server;
import com.pulumi.hcloud.ServerArgs;
import com.pulumi.hcloud.LoadBalancer;
import com.pulumi.hcloud.LoadBalancerArgs;
import com.pulumi.hcloud.inputs.LoadBalancerTargetArgs;
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 myserver = new Server("myserver", ServerArgs.builder()
.serverType("cx11")
.image("ubuntu-18.04")
.build());
var loadBalancer = new LoadBalancer("loadBalancer", LoadBalancerArgs.builder()
.loadBalancerType("lb11")
.location("nbg1")
.targets(LoadBalancerTargetArgs.builder()
.type("server")
.serverId(myserver.id())
.build())
.build());
}
}
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,
}],
});
resources:
myserver:
type: hcloud:Server
properties:
serverType: cx11
image: ubuntu-18.04
loadBalancer:
type: hcloud:LoadBalancer
properties:
loadBalancerType: lb11
location: nbg1
targets:
- type: server
serverId: ${myserver.id}
Create LoadBalancer Resource
new LoadBalancer(name: string, args: LoadBalancerArgs, opts?: CustomResourceOptions);
@overload
def LoadBalancer(resource_name: str,
opts: Optional[ResourceOptions] = None,
algorithm: Optional[LoadBalancerAlgorithmArgs] = None,
delete_protection: Optional[bool] = 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)
@overload
def LoadBalancer(resource_name: str,
args: LoadBalancerArgs,
opts: Optional[ResourceOptions] = None)
func NewLoadBalancer(ctx *Context, name string, args LoadBalancerArgs, opts ...ResourceOption) (*LoadBalancer, error)
public LoadBalancer(string name, LoadBalancerArgs args, CustomResourceOptions? opts = null)
public LoadBalancer(String name, LoadBalancerArgs args)
public LoadBalancer(String name, LoadBalancerArgs args, CustomResourceOptions options)
type: hcloud:LoadBalancer
properties: # The arguments to resource properties.
options: # 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.
- resource_name str
- The unique name of the resource.
- args LoadBalancerArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control 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.
- name String
- The unique name of the resource.
- args LoadBalancerArgs
- The arguments to resource properties.
- options 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 Architecture and Concepts docs.
Inputs
The LoadBalancer resource accepts the following input properties:
- Load
Balancer stringType Type of the Load Balancer.
- Algorithm
Pulumi.
HCloud. Inputs. Load Balancer Algorithm Configuration of the algorithm the Load Balancer use.
- Delete
Protection bool Enable or disable delete protection.
- Labels Dictionary<string, object>
User-defined labels (key-value pairs) should be created with.
- Location string
The location name of the Load Balancer. Require when no network_zone is set.
- Name string
Name of the Load Balancer.
- Network
Zone string The Network Zone of the Load Balancer. Require when no location is set.
- Targets
List<Pulumi.
HCloud. Inputs. Load Balancer Target> Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- Load
Balancer stringType Type of the Load Balancer.
- Algorithm
Load
Balancer Algorithm Args Configuration of the algorithm the Load Balancer use.
- Delete
Protection bool Enable or disable delete protection.
- Labels map[string]interface{}
User-defined labels (key-value pairs) should be created with.
- Location string
The location name of the Load Balancer. Require when no network_zone is set.
- Name string
Name of the Load Balancer.
- Network
Zone string The Network Zone of the Load Balancer. Require when no location is set.
- Targets
[]Load
Balancer Target Type Args Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- load
Balancer StringType Type of the Load Balancer.
- algorithm
Load
Balancer Algorithm Configuration of the algorithm the Load Balancer use.
- delete
Protection Boolean Enable or disable delete protection.
- labels Map<String,Object>
User-defined labels (key-value pairs) should be created with.
- location String
The location name of the Load Balancer. Require when no network_zone is set.
- name String
Name of the Load Balancer.
- network
Zone String The Network Zone of the Load Balancer. Require when no location is set.
- targets
List<Load
Balancer Target> Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- load
Balancer stringType Type of the Load Balancer.
- algorithm
Load
Balancer Algorithm Configuration of the algorithm the Load Balancer use.
- delete
Protection boolean Enable or disable delete protection.
- labels {[key: string]: any}
User-defined labels (key-value pairs) should be created with.
- location string
The location name of the Load Balancer. Require when no network_zone is set.
- name string
Name of the Load Balancer.
- network
Zone string The Network Zone of the Load Balancer. Require when no location is set.
- targets
Load
Balancer Target[] Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- load_
balancer_ strtype Type of the Load Balancer.
- algorithm
Load
Balancer Algorithm Args Configuration of the algorithm the Load Balancer use.
- delete_
protection bool Enable or disable delete protection.
- labels Mapping[str, Any]
User-defined labels (key-value pairs) should be created with.
- location str
The location name of the Load Balancer. Require when no network_zone is set.
- name str
Name of the Load Balancer.
- network_
zone str The Network Zone of the Load Balancer. Require when no location is set.
- targets
Sequence[Load
Balancer Target Args] Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- load
Balancer StringType Type of the Load Balancer.
- algorithm Property Map
Configuration of the algorithm the Load Balancer use.
- delete
Protection Boolean Enable or disable delete protection.
- labels Map<Any>
User-defined labels (key-value pairs) should be created with.
- location String
The location name of the Load Balancer. Require when no network_zone is set.
- name String
Name of the Load Balancer.
- network
Zone String The Network Zone of the Load Balancer. Require when no location is set.
- targets List<Property Map>
Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
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) IPv6 Address of the Load Balancer.
- Network
Id int (int) ID of the first private network that this Load Balancer is connected to.
- Network
Ip string (string) IP of the Load Balancer in the first private network that it is connected to.
- Id string
The provider-assigned unique ID for this managed resource.
- Ipv4 string
(string) IPv4 Address of the Load Balancer.
- Ipv6 string
(string) IPv6 Address of the Load Balancer.
- Network
Id int (int) ID of the first private network that this Load Balancer is connected to.
- Network
Ip string (string) IP of the Load Balancer in the first private network that it is connected to.
- id String
The provider-assigned unique ID for this managed resource.
- ipv4 String
(string) IPv4 Address of the Load Balancer.
- ipv6 String
(string) IPv6 Address of the Load Balancer.
- network
Id Integer (int) ID of the first private network that this Load Balancer is connected to.
- network
Ip String (string) IP of the Load Balancer in the first private network that it is connected to.
- id string
The provider-assigned unique ID for this managed resource.
- ipv4 string
(string) IPv4 Address of the Load Balancer.
- ipv6 string
(string) IPv6 Address of the Load Balancer.
- network
Id number (int) ID of the first private network that this Load Balancer is connected to.
- network
Ip string (string) IP of the Load Balancer in the first private network that it is connected to.
- id str
The provider-assigned unique ID for this managed resource.
- ipv4 str
(string) IPv4 Address of the Load Balancer.
- ipv6 str
(string) IPv6 Address of the Load Balancer.
- network_
id int (int) ID of the first private network that this Load Balancer is connected to.
- network_
ip str (string) IP of the Load Balancer in the first private network that it is connected to.
- id String
The provider-assigned unique ID for this managed resource.
- ipv4 String
(string) IPv4 Address of the Load Balancer.
- ipv6 String
(string) IPv6 Address of the Load Balancer.
- network
Id Number (int) ID of the first private network that this Load Balancer is connected to.
- network
Ip String (string) IP of the Load Balancer in the first private network that it is connected to.
Look up 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,
delete_protection: Optional[bool] = 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)
public static LoadBalancer get(String name, Output<String> id, LoadBalancerState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- 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.
- Algorithm
Pulumi.
HCloud. Inputs. Load Balancer Algorithm Configuration of the algorithm the Load Balancer use.
- Delete
Protection bool Enable or disable delete protection.
- Ipv4 string
(string) IPv4 Address of the Load Balancer.
- Ipv6 string
(string) IPv6 Address of the Load Balancer.
- Labels Dictionary<string, object>
User-defined labels (key-value pairs) should be created with.
- Load
Balancer stringType Type of the Load Balancer.
- Location string
The location name of the Load Balancer. Require when no network_zone is set.
- Name string
Name of the Load Balancer.
- Network
Id int (int) ID of the first private network that this Load Balancer is connected to.
- Network
Ip string (string) IP of the Load Balancer in the first private network that it is connected to.
- Network
Zone string The Network Zone of the Load Balancer. Require when no location is set.
- Targets
List<Pulumi.
HCloud. Inputs. Load Balancer Target> Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- Algorithm
Load
Balancer Algorithm Args Configuration of the algorithm the Load Balancer use.
- Delete
Protection bool Enable or disable delete protection.
- Ipv4 string
(string) IPv4 Address of the Load Balancer.
- Ipv6 string
(string) IPv6 Address of the Load Balancer.
- Labels map[string]interface{}
User-defined labels (key-value pairs) should be created with.
- Load
Balancer stringType Type of the Load Balancer.
- Location string
The location name of the Load Balancer. Require when no network_zone is set.
- Name string
Name of the Load Balancer.
- Network
Id int (int) ID of the first private network that this Load Balancer is connected to.
- Network
Ip string (string) IP of the Load Balancer in the first private network that it is connected to.
- Network
Zone string The Network Zone of the Load Balancer. Require when no location is set.
- Targets
[]Load
Balancer Target Type Args Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- algorithm
Load
Balancer Algorithm Configuration of the algorithm the Load Balancer use.
- delete
Protection Boolean Enable or disable delete protection.
- ipv4 String
(string) IPv4 Address of the Load Balancer.
- ipv6 String
(string) IPv6 Address of the Load Balancer.
- labels Map<String,Object>
User-defined labels (key-value pairs) should be created with.
- load
Balancer StringType Type of the Load Balancer.
- location String
The location name of the Load Balancer. Require when no network_zone is set.
- name String
Name of the Load Balancer.
- network
Id Integer (int) ID of the first private network that this Load Balancer is connected to.
- network
Ip String (string) IP of the Load Balancer in the first private network that it is connected to.
- network
Zone String The Network Zone of the Load Balancer. Require when no location is set.
- targets
List<Load
Balancer Target> Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- algorithm
Load
Balancer Algorithm Configuration of the algorithm the Load Balancer use.
- delete
Protection boolean Enable or disable delete protection.
- ipv4 string
(string) IPv4 Address of the Load Balancer.
- ipv6 string
(string) IPv6 Address of the Load Balancer.
- labels {[key: string]: any}
User-defined labels (key-value pairs) should be created with.
- load
Balancer stringType Type of the Load Balancer.
- location string
The location name of the Load Balancer. Require when no network_zone is set.
- name string
Name of the Load Balancer.
- network
Id number (int) ID of the first private network that this Load Balancer is connected to.
- network
Ip string (string) IP of the Load Balancer in the first private network that it is connected to.
- network
Zone string The Network Zone of the Load Balancer. Require when no location is set.
- targets
Load
Balancer Target[] Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- algorithm
Load
Balancer Algorithm Args Configuration of the algorithm the Load Balancer use.
- delete_
protection bool Enable or disable delete protection.
- ipv4 str
(string) IPv4 Address of the Load Balancer.
- ipv6 str
(string) IPv6 Address of the Load Balancer.
- labels Mapping[str, Any]
User-defined labels (key-value pairs) should be created with.
- load_
balancer_ strtype Type of the Load Balancer.
- location str
The location name of the Load Balancer. Require when no network_zone is set.
- name str
Name of the Load Balancer.
- network_
id int (int) ID of the first private network that this Load Balancer is connected to.
- network_
ip str (string) IP of the Load Balancer in the first private network that it is connected to.
- network_
zone str The Network Zone of the Load Balancer. Require when no location is set.
- targets
Sequence[Load
Balancer Target Args] Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
- algorithm Property Map
Configuration of the algorithm the Load Balancer use.
- delete
Protection Boolean Enable or disable delete protection.
- ipv4 String
(string) IPv4 Address of the Load Balancer.
- ipv6 String
(string) IPv6 Address of the Load Balancer.
- labels Map<Any>
User-defined labels (key-value pairs) should be created with.
- load
Balancer StringType Type of the Load Balancer.
- location String
The location name of the Load Balancer. Require when no network_zone is set.
- name String
Name of the Load Balancer.
- network
Id Number (int) ID of the first private network that this Load Balancer is connected to.
- network
Ip String (string) IP of the Load Balancer in the first private network that it is connected to.
- network
Zone String The Network Zone of the Load Balancer. Require when no location is set.
- targets List<Property Map>
Use hcloud_load_balancer_target resource instead. This allows the full control over the selected targets.
Supporting Types
LoadBalancerAlgorithm, LoadBalancerAlgorithmArgs
- Type string
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- Type string
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- type String
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- type string
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- type str
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- type String
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
LoadBalancerTarget, LoadBalancerTargetArgs
- Type string
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- Server
Id int - Use
Private boolIp Does not work. Use the hcloud_load_balancer_target resource instead.
- Type string
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- Server
Id int - Use
Private boolIp Does not work. Use the hcloud_load_balancer_target resource instead.
- type String
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- server
Id Integer - use
Private BooleanIp Does not work. Use the hcloud_load_balancer_target resource instead.
- type string
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- server
Id number - use
Private booleanIp Does not work. Use the hcloud_load_balancer_target resource instead.
- type str
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- server_
id int - use_
private_ boolip Does not work. Use the hcloud_load_balancer_target resource instead.
- type String
Type of the Load Balancer Algorithm.
round_robin
orleast_connections
- server
Id Number - use
Private BooleanIp 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
- Hetzner Cloud pulumi/pulumi-hcloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
hcloud
Terraform Provider.