Manage the attachment of a Load Balancer in a Network in the Hetzner Cloud.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const main = new hcloud.LoadBalancer("main", {
name: "main",
loadBalancerType: "lb11",
networkZone: "eu-central",
});
const network = new hcloud.Network("network", {
name: "network",
ipRange: "10.0.0.0/16",
});
const subnet = new hcloud.NetworkSubnet("subnet", {
networkId: network.id,
type: "cloud",
networkZone: "eu-central",
ipRange: "10.0.1.0/24",
});
const attachment = new hcloud.LoadBalancerNetwork("attachment", {
loadBalancerId: main.id,
subnetId: subnet.id,
ip: "10.0.1.5",
});
import pulumi
import pulumi_hcloud as hcloud
main = hcloud.LoadBalancer("main",
name="main",
load_balancer_type="lb11",
network_zone="eu-central")
network = hcloud.Network("network",
name="network",
ip_range="10.0.0.0/16")
subnet = hcloud.NetworkSubnet("subnet",
network_id=network.id,
type="cloud",
network_zone="eu-central",
ip_range="10.0.1.0/24")
attachment = hcloud.LoadBalancerNetwork("attachment",
load_balancer_id=main.id,
subnet_id=subnet.id,
ip="10.0.1.5")
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 {
main, err := hcloud.NewLoadBalancer(ctx, "main", &hcloud.LoadBalancerArgs{
Name: pulumi.String("main"),
LoadBalancerType: pulumi.String("lb11"),
NetworkZone: pulumi.String("eu-central"),
})
if err != nil {
return err
}
network, err := hcloud.NewNetwork(ctx, "network", &hcloud.NetworkArgs{
Name: pulumi.String("network"),
IpRange: pulumi.String("10.0.0.0/16"),
})
if err != nil {
return err
}
subnet, err := hcloud.NewNetworkSubnet(ctx, "subnet", &hcloud.NetworkSubnetArgs{
NetworkId: network.ID(),
Type: pulumi.String("cloud"),
NetworkZone: pulumi.String("eu-central"),
IpRange: pulumi.String("10.0.1.0/24"),
})
if err != nil {
return err
}
_, err = hcloud.NewLoadBalancerNetwork(ctx, "attachment", &hcloud.LoadBalancerNetworkArgs{
LoadBalancerId: main.ID(),
SubnetId: subnet.ID(),
Ip: pulumi.String("10.0.1.5"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;
return await Deployment.RunAsync(() =>
{
var main = new HCloud.LoadBalancer("main", new()
{
Name = "main",
LoadBalancerType = "lb11",
NetworkZone = "eu-central",
});
var network = new HCloud.Network("network", new()
{
Name = "network",
IpRange = "10.0.0.0/16",
});
var subnet = new HCloud.NetworkSubnet("subnet", new()
{
NetworkId = network.Id,
Type = "cloud",
NetworkZone = "eu-central",
IpRange = "10.0.1.0/24",
});
var attachment = new HCloud.LoadBalancerNetwork("attachment", new()
{
LoadBalancerId = main.Id,
SubnetId = subnet.Id,
Ip = "10.0.1.5",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.LoadBalancer;
import com.pulumi.hcloud.LoadBalancerArgs;
import com.pulumi.hcloud.Network;
import com.pulumi.hcloud.NetworkArgs;
import com.pulumi.hcloud.NetworkSubnet;
import com.pulumi.hcloud.NetworkSubnetArgs;
import com.pulumi.hcloud.LoadBalancerNetwork;
import com.pulumi.hcloud.LoadBalancerNetworkArgs;
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 main = new LoadBalancer("main", LoadBalancerArgs.builder()
.name("main")
.loadBalancerType("lb11")
.networkZone("eu-central")
.build());
var network = new Network("network", NetworkArgs.builder()
.name("network")
.ipRange("10.0.0.0/16")
.build());
var subnet = new NetworkSubnet("subnet", NetworkSubnetArgs.builder()
.networkId(network.id())
.type("cloud")
.networkZone("eu-central")
.ipRange("10.0.1.0/24")
.build());
var attachment = new LoadBalancerNetwork("attachment", LoadBalancerNetworkArgs.builder()
.loadBalancerId(main.id())
.subnetId(subnet.id())
.ip("10.0.1.5")
.build());
}
}
resources:
main:
type: hcloud:LoadBalancer
properties:
name: main
loadBalancerType: lb11
networkZone: eu-central
network:
type: hcloud:Network
properties:
name: network
ipRange: 10.0.0.0/16
subnet:
type: hcloud:NetworkSubnet
properties:
networkId: ${network.id}
type: cloud
networkZone: eu-central
ipRange: 10.0.1.0/24
attachment:
type: hcloud:LoadBalancerNetwork
properties:
loadBalancerId: ${main.id}
subnetId: ${subnet.id}
ip: 10.0.1.5
Create LoadBalancerNetwork Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new LoadBalancerNetwork(name: string, args: LoadBalancerNetworkArgs, opts?: CustomResourceOptions);@overload
def LoadBalancerNetwork(resource_name: str,
args: LoadBalancerNetworkArgs,
opts: Optional[ResourceOptions] = None)
@overload
def LoadBalancerNetwork(resource_name: str,
opts: Optional[ResourceOptions] = None,
load_balancer_id: Optional[int] = None,
enable_public_interface: Optional[bool] = None,
ip: Optional[str] = None,
network_id: Optional[int] = None,
subnet_id: Optional[str] = None)func NewLoadBalancerNetwork(ctx *Context, name string, args LoadBalancerNetworkArgs, opts ...ResourceOption) (*LoadBalancerNetwork, error)public LoadBalancerNetwork(string name, LoadBalancerNetworkArgs args, CustomResourceOptions? opts = null)
public LoadBalancerNetwork(String name, LoadBalancerNetworkArgs args)
public LoadBalancerNetwork(String name, LoadBalancerNetworkArgs args, CustomResourceOptions options)
type: hcloud:LoadBalancerNetwork
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args LoadBalancerNetworkArgs
- 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 LoadBalancerNetworkArgs
- 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 LoadBalancerNetworkArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args LoadBalancerNetworkArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args LoadBalancerNetworkArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var loadBalancerNetworkResource = new HCloud.LoadBalancerNetwork("loadBalancerNetworkResource", new()
{
LoadBalancerId = 0,
EnablePublicInterface = false,
Ip = "string",
NetworkId = 0,
SubnetId = "string",
});
example, err := hcloud.NewLoadBalancerNetwork(ctx, "loadBalancerNetworkResource", &hcloud.LoadBalancerNetworkArgs{
LoadBalancerId: pulumi.Int(0),
EnablePublicInterface: pulumi.Bool(false),
Ip: pulumi.String("string"),
NetworkId: pulumi.Int(0),
SubnetId: pulumi.String("string"),
})
var loadBalancerNetworkResource = new LoadBalancerNetwork("loadBalancerNetworkResource", LoadBalancerNetworkArgs.builder()
.loadBalancerId(0)
.enablePublicInterface(false)
.ip("string")
.networkId(0)
.subnetId("string")
.build());
load_balancer_network_resource = hcloud.LoadBalancerNetwork("loadBalancerNetworkResource",
load_balancer_id=0,
enable_public_interface=False,
ip="string",
network_id=0,
subnet_id="string")
const loadBalancerNetworkResource = new hcloud.LoadBalancerNetwork("loadBalancerNetworkResource", {
loadBalancerId: 0,
enablePublicInterface: false,
ip: "string",
networkId: 0,
subnetId: "string",
});
type: hcloud:LoadBalancerNetwork
properties:
enablePublicInterface: false
ip: string
loadBalancerId: 0
networkId: 0
subnetId: string
LoadBalancerNetwork Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The LoadBalancerNetwork resource accepts the following input properties:
- Load
Balancer intId - ID of the Load Balancer.
- Enable
Public boolInterface - Wether the Load Balancer public interface is enabled. Default is
true. - Ip string
- IP to assign to the Load Balancer.
- Network
Id int - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - Subnet
Id string - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- Load
Balancer intId - ID of the Load Balancer.
- Enable
Public boolInterface - Wether the Load Balancer public interface is enabled. Default is
true. - Ip string
- IP to assign to the Load Balancer.
- Network
Id int - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - Subnet
Id string - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- load
Balancer IntegerId - ID of the Load Balancer.
- enable
Public BooleanInterface - Wether the Load Balancer public interface is enabled. Default is
true. - ip String
- IP to assign to the Load Balancer.
- network
Id Integer - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - subnet
Id String - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- load
Balancer numberId - ID of the Load Balancer.
- enable
Public booleanInterface - Wether the Load Balancer public interface is enabled. Default is
true. - ip string
- IP to assign to the Load Balancer.
- network
Id number - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - subnet
Id string - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- load_
balancer_ intid - ID of the Load Balancer.
- enable_
public_ boolinterface - Wether the Load Balancer public interface is enabled. Default is
true. - ip str
- IP to assign to the Load Balancer.
- network_
id int - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - subnet_
id str - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- load
Balancer NumberId - ID of the Load Balancer.
- enable
Public BooleanInterface - Wether the Load Balancer public interface is enabled. Default is
true. - ip String
- IP to assign to the Load Balancer.
- network
Id Number - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - subnet
Id String - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
Outputs
All input properties are implicitly available as output properties. Additionally, the LoadBalancerNetwork resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing LoadBalancerNetwork Resource
Get an existing LoadBalancerNetwork 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?: LoadBalancerNetworkState, opts?: CustomResourceOptions): LoadBalancerNetwork@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
enable_public_interface: Optional[bool] = None,
ip: Optional[str] = None,
load_balancer_id: Optional[int] = None,
network_id: Optional[int] = None,
subnet_id: Optional[str] = None) -> LoadBalancerNetworkfunc GetLoadBalancerNetwork(ctx *Context, name string, id IDInput, state *LoadBalancerNetworkState, opts ...ResourceOption) (*LoadBalancerNetwork, error)public static LoadBalancerNetwork Get(string name, Input<string> id, LoadBalancerNetworkState? state, CustomResourceOptions? opts = null)public static LoadBalancerNetwork get(String name, Output<String> id, LoadBalancerNetworkState state, CustomResourceOptions options)resources: _: type: hcloud:LoadBalancerNetwork get: id: ${id}- 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.
- Enable
Public boolInterface - Wether the Load Balancer public interface is enabled. Default is
true. - Ip string
- IP to assign to the Load Balancer.
- Load
Balancer intId - ID of the Load Balancer.
- Network
Id int - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - Subnet
Id string - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- Enable
Public boolInterface - Wether the Load Balancer public interface is enabled. Default is
true. - Ip string
- IP to assign to the Load Balancer.
- Load
Balancer intId - ID of the Load Balancer.
- Network
Id int - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - Subnet
Id string - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- enable
Public BooleanInterface - Wether the Load Balancer public interface is enabled. Default is
true. - ip String
- IP to assign to the Load Balancer.
- load
Balancer IntegerId - ID of the Load Balancer.
- network
Id Integer - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - subnet
Id String - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- enable
Public booleanInterface - Wether the Load Balancer public interface is enabled. Default is
true. - ip string
- IP to assign to the Load Balancer.
- load
Balancer numberId - ID of the Load Balancer.
- network
Id number - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - subnet
Id string - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- enable_
public_ boolinterface - Wether the Load Balancer public interface is enabled. Default is
true. - ip str
- IP to assign to the Load Balancer.
- load_
balancer_ intid - ID of the Load Balancer.
- network_
id int - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - subnet_
id str - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
- enable
Public BooleanInterface - Wether the Load Balancer public interface is enabled. Default is
true. - ip String
- IP to assign to the Load Balancer.
- load
Balancer NumberId - ID of the Load Balancer.
- network
Id Number - ID of the Network to attach the Load Balancer to. Using
subnet_idis preferred. Required ifsubnet_idis not set. Ifsubnet_idoripare not set, the Load Balancer will be attached to the last subnet (ordered byip_range). - subnet
Id String - ID of the Subnet to attach the Load Balancer to. Required if
network_idis not set.
Import
In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:
terraform
import {
id = “${hcloud_load_balancer.example.id}-${hcloud_network.example.id}”
to = hcloud_load_balancer_network.attachment
}
The pulumi import command can be used, for example:
$ pulumi import hcloud:index/loadBalancerNetwork:LoadBalancerNetwork example "$LOAD_BALANCER_ID-$NETWORK_ID"
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Hetzner Cloud pulumi/pulumi-hcloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
hcloudTerraform Provider.
