Hetzner Cloud

v1.10.1 published on Wednesday, Aug 3, 2022 by Pulumi

LoadBalancerTarget

Adds a target to a Hetzner Cloud Load Balancer.

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",
        });
        var loadBalancerTarget = new HCloud.LoadBalancerTarget("loadBalancerTarget", new HCloud.LoadBalancerTargetArgs
        {
            Type = "server",
            LoadBalancerId = loadBalancer.Id,
            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
		}
		loadBalancer, err := hcloud.NewLoadBalancer(ctx, "loadBalancer", &hcloud.LoadBalancerArgs{
			LoadBalancerType: pulumi.String("lb11"),
			Location:         pulumi.String("nbg1"),
		})
		if err != nil {
			return err
		}
		_, err = hcloud.NewLoadBalancerTarget(ctx, "loadBalancerTarget", &hcloud.LoadBalancerTargetArgs{
			Type:           pulumi.String("server"),
			LoadBalancerId: loadBalancer.ID(),
			ServerId:       myServer.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

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")
            .build());

        var loadBalancerTarget = new LoadBalancerTarget("loadBalancerTarget", LoadBalancerTargetArgs.builder()        
            .type("server")
            .loadBalancerId(loadBalancer.id())
            .serverId(myServer.id())
            .build());

    }
}
import pulumi
import pulumi_hcloud as hcloud

my_server = hcloud.Server("myServer",
    server_type="cx11",
    image="ubuntu-18.04")
load_balancer = hcloud.LoadBalancer("loadBalancer",
    load_balancer_type="lb11",
    location="nbg1")
load_balancer_target = hcloud.LoadBalancerTarget("loadBalancerTarget",
    type="server",
    load_balancer_id=load_balancer.id,
    server_id=my_server.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",
});
const loadBalancerTarget = new hcloud.LoadBalancerTarget("loadBalancerTarget", {
    type: "server",
    loadBalancerId: loadBalancer.id,
    serverId: myServer.id,
});
resources:
  myServer:
    type: hcloud:Server
    properties:
      serverType: cx11
      image: ubuntu-18.04
  loadBalancer:
    type: hcloud:LoadBalancer
    properties:
      loadBalancerType: lb11
      location: nbg1
  loadBalancerTarget:
    type: hcloud:LoadBalancerTarget
    properties:
      type: server
      loadBalancerId: ${loadBalancer.id}
      serverId: ${myServer.id}

Create LoadBalancerTarget Resource

new LoadBalancerTarget(name: string, args: LoadBalancerTargetArgs, opts?: CustomResourceOptions);
@overload
def LoadBalancerTarget(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       ip: Optional[str] = None,
                       label_selector: Optional[str] = None,
                       load_balancer_id: Optional[int] = None,
                       server_id: Optional[int] = None,
                       type: Optional[str] = None,
                       use_private_ip: Optional[bool] = None)
@overload
def LoadBalancerTarget(resource_name: str,
                       args: LoadBalancerTargetInitArgs,
                       opts: Optional[ResourceOptions] = None)
func NewLoadBalancerTarget(ctx *Context, name string, args LoadBalancerTargetArgs, opts ...ResourceOption) (*LoadBalancerTarget, error)
public LoadBalancerTarget(string name, LoadBalancerTargetArgs args, CustomResourceOptions? opts = null)
public LoadBalancerTarget(String name, LoadBalancerTargetArgs args)
public LoadBalancerTarget(String name, LoadBalancerTargetArgs args, CustomResourceOptions options)
type: hcloud:LoadBalancerTarget
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args LoadBalancerTargetArgs
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 LoadBalancerTargetInitArgs
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 LoadBalancerTargetArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args LoadBalancerTargetArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args LoadBalancerTargetArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

LoadBalancerTarget 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 LoadBalancerTarget resource accepts the following input properties:

LoadBalancerId int

ID of the Load Balancer to which the target gets attached.

Type string

Type of the target. Possible values server, label_selector, ip.

Ip string

IP address for an IP Target. Required if type is ip.

LabelSelector string

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

ServerId int

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

UsePrivateIp bool

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

LoadBalancerId int

ID of the Load Balancer to which the target gets attached.

Type string

Type of the target. Possible values server, label_selector, ip.

Ip string

IP address for an IP Target. Required if type is ip.

LabelSelector string

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

ServerId int

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

UsePrivateIp bool

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

loadBalancerId Integer

ID of the Load Balancer to which the target gets attached.

type String

Type of the target. Possible values server, label_selector, ip.

ip String

IP address for an IP Target. Required if type is ip.

labelSelector String

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

serverId Integer

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

usePrivateIp Boolean

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

loadBalancerId number

ID of the Load Balancer to which the target gets attached.

type string

Type of the target. Possible values server, label_selector, ip.

ip string

IP address for an IP Target. Required if type is ip.

labelSelector string

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

serverId number

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

usePrivateIp boolean

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

load_balancer_id int

ID of the Load Balancer to which the target gets attached.

type str

Type of the target. Possible values server, label_selector, ip.

ip str

IP address for an IP Target. Required if type is ip.

label_selector str

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

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

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

loadBalancerId Number

ID of the Load Balancer to which the target gets attached.

type String

Type of the target. Possible values server, label_selector, ip.

ip String

IP address for an IP Target. Required if type is ip.

labelSelector String

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

serverId Number

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

usePrivateIp Boolean

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

Outputs

All input properties are implicitly available as output properties. Additionally, the LoadBalancerTarget 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 LoadBalancerTarget Resource

Get an existing LoadBalancerTarget 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?: LoadBalancerTargetState, opts?: CustomResourceOptions): LoadBalancerTarget
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        ip: Optional[str] = None,
        label_selector: Optional[str] = None,
        load_balancer_id: Optional[int] = None,
        server_id: Optional[int] = None,
        type: Optional[str] = None,
        use_private_ip: Optional[bool] = None) -> LoadBalancerTarget
func GetLoadBalancerTarget(ctx *Context, name string, id IDInput, state *LoadBalancerTargetState, opts ...ResourceOption) (*LoadBalancerTarget, error)
public static LoadBalancerTarget Get(string name, Input<string> id, LoadBalancerTargetState? state, CustomResourceOptions? opts = null)
public static LoadBalancerTarget get(String name, Output<String> id, LoadBalancerTargetState 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.
The following state arguments are supported:
Ip string

IP address for an IP Target. Required if type is ip.

LabelSelector string

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

LoadBalancerId int

ID of the Load Balancer to which the target gets attached.

ServerId int

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

Type string

Type of the target. Possible values server, label_selector, ip.

UsePrivateIp bool

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

Ip string

IP address for an IP Target. Required if type is ip.

LabelSelector string

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

LoadBalancerId int

ID of the Load Balancer to which the target gets attached.

ServerId int

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

Type string

Type of the target. Possible values server, label_selector, ip.

UsePrivateIp bool

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

ip String

IP address for an IP Target. Required if type is ip.

labelSelector String

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

loadBalancerId Integer

ID of the Load Balancer to which the target gets attached.

serverId Integer

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

type String

Type of the target. Possible values server, label_selector, ip.

usePrivateIp Boolean

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

ip string

IP address for an IP Target. Required if type is ip.

labelSelector string

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

loadBalancerId number

ID of the Load Balancer to which the target gets attached.

serverId number

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

type string

Type of the target. Possible values server, label_selector, ip.

usePrivateIp boolean

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

ip str

IP address for an IP Target. Required if type is ip.

label_selector str

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

load_balancer_id int

ID of the Load Balancer to which the target gets attached.

server_id int

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

type str

Type of the target. Possible values server, label_selector, ip.

use_private_ip bool

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

ip String

IP address for an IP Target. Required if type is ip.

labelSelector String

Label Selector selecting targets for this Load Balancer. Required if type is label_selector.

loadBalancerId Number

ID of the Load Balancer to which the target gets attached.

serverId Number

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

type String

Type of the target. Possible values server, label_selector, ip.

usePrivateIp Boolean

use the private IP to connect to Load Balancer targets. Only allowed if type is server or label_selector.

Package Details

Repository
https://github.com/pulumi/pulumi-hcloud
License
Apache-2.0
Notes

This Pulumi package is based on the hcloud Terraform Provider.