hcloud.LoadBalancerTarget
Explore with Pulumi AI
Adds a target to a Hetzner Cloud Load Balancer.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const myServer = new hcloud.Server("my_server", {
name: "my-server",
serverType: "cx11",
image: "ubuntu-18.04",
});
const loadBalancer = new hcloud.LoadBalancer("load_balancer", {
name: "my-load-balancer",
loadBalancerType: "lb11",
location: "nbg1",
});
const loadBalancerTarget = new hcloud.LoadBalancerTarget("load_balancer_target", {
type: "server",
loadBalancerId: loadBalancer.id,
serverId: myServer.id,
});
import pulumi
import pulumi_hcloud as hcloud
my_server = hcloud.Server("my_server",
name="my-server",
server_type="cx11",
image="ubuntu-18.04")
load_balancer = hcloud.LoadBalancer("load_balancer",
name="my-load-balancer",
load_balancer_type="lb11",
location="nbg1")
load_balancer_target = hcloud.LoadBalancerTarget("load_balancer_target",
type="server",
load_balancer_id=load_balancer.id,
server_id=my_server.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, "my_server", &hcloud.ServerArgs{
Name: pulumi.String("my-server"),
ServerType: pulumi.String("cx11"),
Image: pulumi.String("ubuntu-18.04"),
})
if err != nil {
return err
}
loadBalancer, err := hcloud.NewLoadBalancer(ctx, "load_balancer", &hcloud.LoadBalancerArgs{
Name: pulumi.String("my-load-balancer"),
LoadBalancerType: pulumi.String("lb11"),
Location: pulumi.String("nbg1"),
})
if err != nil {
return err
}
_, err = hcloud.NewLoadBalancerTarget(ctx, "load_balancer_target", &hcloud.LoadBalancerTargetArgs{
Type: pulumi.String("server"),
LoadBalancerId: loadBalancer.ID(),
ServerId: myServer.ID(),
})
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 myServer = new HCloud.Server("my_server", new()
{
Name = "my-server",
ServerType = "cx11",
Image = "ubuntu-18.04",
});
var loadBalancer = new HCloud.LoadBalancer("load_balancer", new()
{
Name = "my-load-balancer",
LoadBalancerType = "lb11",
Location = "nbg1",
});
var loadBalancerTarget = new HCloud.LoadBalancerTarget("load_balancer_target", new()
{
Type = "server",
LoadBalancerId = loadBalancer.Id,
ServerId = myServer.Id,
});
});
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.LoadBalancerTarget;
import com.pulumi.hcloud.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()
.name("my-server")
.serverType("cx11")
.image("ubuntu-18.04")
.build());
var loadBalancer = new LoadBalancer("loadBalancer", LoadBalancerArgs.builder()
.name("my-load-balancer")
.loadBalancerType("lb11")
.location("nbg1")
.build());
var loadBalancerTarget = new LoadBalancerTarget("loadBalancerTarget", LoadBalancerTargetArgs.builder()
.type("server")
.loadBalancerId(loadBalancer.id())
.serverId(myServer.id())
.build());
}
}
resources:
myServer:
type: hcloud:Server
name: my_server
properties:
name: my-server
serverType: cx11
image: ubuntu-18.04
loadBalancer:
type: hcloud:LoadBalancer
name: load_balancer
properties:
name: my-load-balancer
loadBalancerType: lb11
location: nbg1
loadBalancerTarget:
type: hcloud:LoadBalancerTarget
name: load_balancer_target
properties:
type: server
loadBalancerId: ${loadBalancer.id}
serverId: ${myServer.id}
Create LoadBalancerTarget Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new LoadBalancerTarget(name: string, args: LoadBalancerTargetArgs, opts?: CustomResourceOptions);
@overload
def LoadBalancerTarget(resource_name: str,
args: LoadBalancerTargetInitArgs,
opts: Optional[ResourceOptions] = None)
@overload
def LoadBalancerTarget(resource_name: str,
opts: Optional[ResourceOptions] = None,
load_balancer_id: Optional[int] = None,
type: Optional[str] = None,
ip: Optional[str] = None,
label_selector: Optional[str] = None,
server_id: Optional[int] = None,
use_private_ip: Optional[bool] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var loadBalancerTargetResource = new HCloud.LoadBalancerTarget("loadBalancerTargetResource", new()
{
LoadBalancerId = 0,
Type = "string",
Ip = "string",
LabelSelector = "string",
ServerId = 0,
UsePrivateIp = false,
});
example, err := hcloud.NewLoadBalancerTarget(ctx, "loadBalancerTargetResource", &hcloud.LoadBalancerTargetArgs{
LoadBalancerId: pulumi.Int(0),
Type: pulumi.String("string"),
Ip: pulumi.String("string"),
LabelSelector: pulumi.String("string"),
ServerId: pulumi.Int(0),
UsePrivateIp: pulumi.Bool(false),
})
var loadBalancerTargetResource = new LoadBalancerTarget("loadBalancerTargetResource", LoadBalancerTargetArgs.builder()
.loadBalancerId(0)
.type("string")
.ip("string")
.labelSelector("string")
.serverId(0)
.usePrivateIp(false)
.build());
load_balancer_target_resource = hcloud.LoadBalancerTarget("loadBalancerTargetResource",
load_balancer_id=0,
type="string",
ip="string",
label_selector="string",
server_id=0,
use_private_ip=False)
const loadBalancerTargetResource = new hcloud.LoadBalancerTarget("loadBalancerTargetResource", {
loadBalancerId: 0,
type: "string",
ip: "string",
labelSelector: "string",
serverId: 0,
usePrivateIp: false,
});
type: hcloud:LoadBalancerTarget
properties:
ip: string
labelSelector: string
loadBalancerId: 0
serverId: 0
type: string
usePrivateIp: false
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:
- Load
Balancer intId - 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
isip
. - Label
Selector string - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - Server
Id int - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- Use
Private boolIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- Load
Balancer intId - 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
isip
. - Label
Selector string - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - Server
Id int - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- Use
Private boolIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- load
Balancer IntegerId - 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
isip
. - label
Selector String - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - server
Id Integer - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- use
Private BooleanIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- load
Balancer numberId - 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
isip
. - label
Selector string - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - server
Id number - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- use
Private booleanIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- load_
balancer_ intid - 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
isip
. - label_
selector str - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - server_
id int - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- use_
private_ boolip - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- load
Balancer NumberId - 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
isip
. - label
Selector String - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - server
Id Number - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- use
Private BooleanIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_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.
- Ip string
- IP address for an IP Target. Required if
type
isip
. - Label
Selector string - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - Load
Balancer intId - 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
isserver
- Type string
- Type of the target. Possible values
server
,label_selector
,ip
. - Use
Private boolIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- Ip string
- IP address for an IP Target. Required if
type
isip
. - Label
Selector string - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - Load
Balancer intId - 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
isserver
- Type string
- Type of the target. Possible values
server
,label_selector
,ip
. - Use
Private boolIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- ip String
- IP address for an IP Target. Required if
type
isip
. - label
Selector String - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - load
Balancer IntegerId - ID of the Load Balancer to which the target gets attached.
- server
Id Integer - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- type String
- Type of the target. Possible values
server
,label_selector
,ip
. - use
Private BooleanIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- ip string
- IP address for an IP Target. Required if
type
isip
. - label
Selector string - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - load
Balancer numberId - ID of the Load Balancer to which the target gets attached.
- server
Id number - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- type string
- Type of the target. Possible values
server
,label_selector
,ip
. - use
Private booleanIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- ip str
- IP address for an IP Target. Required if
type
isip
. - label_
selector str - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - load_
balancer_ intid - 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
isserver
- type str
- Type of the target. Possible values
server
,label_selector
,ip
. - use_
private_ boolip - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
- ip String
- IP address for an IP Target. Required if
type
isip
. - label
Selector String - Label Selector selecting targets
for this Load Balancer. Required if
type
islabel_selector
. - load
Balancer NumberId - ID of the Load Balancer to which the target gets attached.
- server
Id Number - ID of the server which should be a
target for this Load Balancer. Required if
type
isserver
- type String
- Type of the target. Possible values
server
,label_selector
,ip
. - use
Private BooleanIp - use the private IP to connect to
Load Balancer targets. Only allowed if type is
server
orlabel_selector
.
Import
Load Balancer Target entries can be imported using a compound ID with the following format:
<load-balancer-id>__<type>__<identifier>
Where identifier depends on the type:
server
: server id, for example:123
label_selector
: label selector, for example:foo=bar
ip
: ip address, for example:203.0.113.123
$ pulumi import hcloud:index/loadBalancerTarget:LoadBalancerTarget myloadbalancerservertarget 123__server__321
$ pulumi import hcloud:index/loadBalancerTarget:LoadBalancerTarget myloadbalancerlabeltarget 123__label_selector__foo=bar
$ pulumi import hcloud:index/loadBalancerTarget:LoadBalancerTarget myloadbalanceriptarget 123__ip__203.0.113.123
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
hcloud
Terraform Provider.