Hetzner Cloud

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

getServer

Example Usage

using Pulumi;
using HCloud = Pulumi.HCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var s1 = Output.Create(HCloud.GetServer.InvokeAsync(new HCloud.GetServerArgs
        {
            Name = "my-server",
        }));
        var s2 = Output.Create(HCloud.GetServer.InvokeAsync(new HCloud.GetServerArgs
        {
            Id = 123,
        }));
        var s3 = Output.Create(HCloud.GetServer.InvokeAsync(new HCloud.GetServerArgs
        {
            WithSelector = "key=value",
        }));
    }

}
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 {
		_, err := hcloud.LookupServer(ctx, &GetServerArgs{
			Name: pulumi.StringRef("my-server"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = hcloud.LookupServer(ctx, &GetServerArgs{
			Id: pulumi.IntRef(123),
		}, nil)
		if err != nil {
			return err
		}
		_, err = hcloud.LookupServer(ctx, &GetServerArgs{
			WithSelector: pulumi.StringRef("key=value"),
		}, nil)
		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) {
        final var s1 = Output.of(HcloudFunctions.getServer(GetServerArgs.builder()
            .name("my-server")
            .build()));

        final var s2 = Output.of(HcloudFunctions.getServer(GetServerArgs.builder()
            .id("123")
            .build()));

        final var s3 = Output.of(HcloudFunctions.getServer(GetServerArgs.builder()
            .withSelector("key=value")
            .build()));

    }
}
import pulumi
import pulumi_hcloud as hcloud

s1 = hcloud.get_server(name="my-server")
s2 = hcloud.get_server(id=123)
s3 = hcloud.get_server(with_selector="key=value")
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const s1 = pulumi.output(hcloud.getServer({
    name: "my-server",
}));
const s2 = pulumi.output(hcloud.getServer({
    id: 123,
}));
const s3 = pulumi.output(hcloud.getServer({
    withSelector: "key=value",
}));
variables:
  s1:
    Fn::Invoke:
      Function: hcloud:getServer
      Arguments:
        name: my-server
  s2:
    Fn::Invoke:
      Function: hcloud:getServer
      Arguments:
        id: 123
  s3:
    Fn::Invoke:
      Function: hcloud:getServer
      Arguments:
        withSelector: key=value

Using getServer

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getServer(args: GetServerArgs, opts?: InvokeOptions): Promise<GetServerResult>
function getServerOutput(args: GetServerOutputArgs, opts?: InvokeOptions): Output<GetServerResult>
def get_server(id: Optional[int] = None,
               name: Optional[str] = None,
               placement_group_id: Optional[int] = None,
               selector: Optional[str] = None,
               with_selector: Optional[str] = None,
               with_statuses: Optional[Sequence[str]] = None,
               opts: Optional[InvokeOptions] = None) -> GetServerResult
def get_server_output(id: Optional[pulumi.Input[int]] = None,
               name: Optional[pulumi.Input[str]] = None,
               placement_group_id: Optional[pulumi.Input[int]] = None,
               selector: Optional[pulumi.Input[str]] = None,
               with_selector: Optional[pulumi.Input[str]] = None,
               with_statuses: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetServerResult]
func LookupServer(ctx *Context, args *LookupServerArgs, opts ...InvokeOption) (*LookupServerResult, error)
func LookupServerOutput(ctx *Context, args *LookupServerOutputArgs, opts ...InvokeOption) LookupServerResultOutput

> Note: This function is named LookupServer in the Go SDK.

public static class GetServer 
{
    public static Task<GetServerResult> InvokeAsync(GetServerArgs args, InvokeOptions? opts = null)
    public static Output<GetServerResult> Invoke(GetServerInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetServerResult> getServer(GetServerArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: hcloud:index/getServer:getServer
  arguments:
    # arguments dictionary

The following arguments are supported:

Id int

ID of the server.

Name string

Name of the server.

PlacementGroupId int

(Optional, string) Placement Group ID the server is assigned to.

Selector string

Deprecated:

Please use the with_selector property instead.

WithSelector string

Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.

WithStatuses List<string>

List only servers with the specified status, could contain initializing, starting, running, stopping, off, deleting, rebuilding, migrating, unknown.

Id int

ID of the server.

Name string

Name of the server.

PlacementGroupId int

(Optional, string) Placement Group ID the server is assigned to.

Selector string

Deprecated:

Please use the with_selector property instead.

WithSelector string

Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.

WithStatuses []string

List only servers with the specified status, could contain initializing, starting, running, stopping, off, deleting, rebuilding, migrating, unknown.

id Integer

ID of the server.

name String

Name of the server.

placementGroupId Integer

(Optional, string) Placement Group ID the server is assigned to.

selector String

Deprecated:

Please use the with_selector property instead.

withSelector String

Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.

withStatuses List<String>

List only servers with the specified status, could contain initializing, starting, running, stopping, off, deleting, rebuilding, migrating, unknown.

id number

ID of the server.

name string

Name of the server.

placementGroupId number

(Optional, string) Placement Group ID the server is assigned to.

selector string

Deprecated:

Please use the with_selector property instead.

withSelector string

Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.

withStatuses string[]

List only servers with the specified status, could contain initializing, starting, running, stopping, off, deleting, rebuilding, migrating, unknown.

id int

ID of the server.

name str

Name of the server.

placement_group_id int

(Optional, string) Placement Group ID the server is assigned to.

selector str

Deprecated:

Please use the with_selector property instead.

with_selector str

Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.

with_statuses Sequence[str]

List only servers with the specified status, could contain initializing, starting, running, stopping, off, deleting, rebuilding, migrating, unknown.

id Number

ID of the server.

name String

Name of the server.

placementGroupId Number

(Optional, string) Placement Group ID the server is assigned to.

selector String

Deprecated:

Please use the with_selector property instead.

withSelector String

Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.

withStatuses List<String>

List only servers with the specified status, could contain initializing, starting, running, stopping, off, deleting, rebuilding, migrating, unknown.

getServer Result

The following output properties are available:

BackupWindow string

(string) The backup window of the server, if enabled.

Backups bool

(boolean) Whether backups are enabled.

Datacenter string

(string) The datacenter name.

DeleteProtection bool

(boolean) Whether delete protection is enabled.

FirewallIds List<int>

(Optional, list) Firewall IDs the server is attached to.

Id int

(int) Unique ID of the server.

Image string

(string) Name or ID of the image the server was created from.

Ipv4Address string

(string) The IPv4 address.

Ipv6Address string

(string) The first IPv6 address of the assigned network.

Ipv6Network string

(string) The IPv6 network.

Iso string

(string) ID or Name of the mounted ISO image.

Labels Dictionary<string, object>

(map) User-defined labels (key-value pairs)

Location string

(string) The location name.

Name string

(string) Name of the server.

RebuildProtection bool

(boolean) Whether rebuild protection is enabled.

Rescue string
ServerType string

(string) Name of the server type.

Status string

(string) The status of the server.

PlacementGroupId int

(Optional, string) Placement Group ID the server is assigned to.

Selector string

Deprecated:

Please use the with_selector property instead.

WithSelector string
WithStatuses List<string>
BackupWindow string

(string) The backup window of the server, if enabled.

Backups bool

(boolean) Whether backups are enabled.

Datacenter string

(string) The datacenter name.

DeleteProtection bool

(boolean) Whether delete protection is enabled.

FirewallIds []int

(Optional, list) Firewall IDs the server is attached to.

Id int

(int) Unique ID of the server.

Image string

(string) Name or ID of the image the server was created from.

Ipv4Address string

(string) The IPv4 address.

Ipv6Address string

(string) The first IPv6 address of the assigned network.

Ipv6Network string

(string) The IPv6 network.

Iso string

(string) ID or Name of the mounted ISO image.

Labels map[string]interface{}

(map) User-defined labels (key-value pairs)

Location string

(string) The location name.

Name string

(string) Name of the server.

RebuildProtection bool

(boolean) Whether rebuild protection is enabled.

Rescue string
ServerType string

(string) Name of the server type.

Status string

(string) The status of the server.

PlacementGroupId int

(Optional, string) Placement Group ID the server is assigned to.

Selector string

Deprecated:

Please use the with_selector property instead.

WithSelector string
WithStatuses []string
backupWindow String

(string) The backup window of the server, if enabled.

backups Boolean

(boolean) Whether backups are enabled.

datacenter String

(string) The datacenter name.

deleteProtection Boolean

(boolean) Whether delete protection is enabled.

firewallIds List<Integer>

(Optional, list) Firewall IDs the server is attached to.

id Integer

(int) Unique ID of the server.

image String

(string) Name or ID of the image the server was created from.

ipv4Address String

(string) The IPv4 address.

ipv6Address String

(string) The first IPv6 address of the assigned network.

ipv6Network String

(string) The IPv6 network.

iso String

(string) ID or Name of the mounted ISO image.

labels Map<String,Object>

(map) User-defined labels (key-value pairs)

location String

(string) The location name.

name String

(string) Name of the server.

rebuildProtection Boolean

(boolean) Whether rebuild protection is enabled.

rescue String
serverType String

(string) Name of the server type.

status String

(string) The status of the server.

placementGroupId Integer

(Optional, string) Placement Group ID the server is assigned to.

selector String

Deprecated:

Please use the with_selector property instead.

withSelector String
withStatuses List<String>
backupWindow string

(string) The backup window of the server, if enabled.

backups boolean

(boolean) Whether backups are enabled.

datacenter string

(string) The datacenter name.

deleteProtection boolean

(boolean) Whether delete protection is enabled.

firewallIds number[]

(Optional, list) Firewall IDs the server is attached to.

id number

(int) Unique ID of the server.

image string

(string) Name or ID of the image the server was created from.

ipv4Address string

(string) The IPv4 address.

ipv6Address string

(string) The first IPv6 address of the assigned network.

ipv6Network string

(string) The IPv6 network.

iso string

(string) ID or Name of the mounted ISO image.

labels {[key: string]: any}

(map) User-defined labels (key-value pairs)

location string

(string) The location name.

name string

(string) Name of the server.

rebuildProtection boolean

(boolean) Whether rebuild protection is enabled.

rescue string
serverType string

(string) Name of the server type.

status string

(string) The status of the server.

placementGroupId number

(Optional, string) Placement Group ID the server is assigned to.

selector string

Deprecated:

Please use the with_selector property instead.

withSelector string
withStatuses string[]
backup_window str

(string) The backup window of the server, if enabled.

backups bool

(boolean) Whether backups are enabled.

datacenter str

(string) The datacenter name.

delete_protection bool

(boolean) Whether delete protection is enabled.

firewall_ids Sequence[int]

(Optional, list) Firewall IDs the server is attached to.

id int

(int) Unique ID of the server.

image str

(string) Name or ID of the image the server was created from.

ipv4_address str

(string) The IPv4 address.

ipv6_address str

(string) The first IPv6 address of the assigned network.

ipv6_network str

(string) The IPv6 network.

iso str

(string) ID or Name of the mounted ISO image.

labels Mapping[str, Any]

(map) User-defined labels (key-value pairs)

location str

(string) The location name.

name str

(string) Name of the server.

rebuild_protection bool

(boolean) Whether rebuild protection is enabled.

rescue str
server_type str

(string) Name of the server type.

status str

(string) The status of the server.

placement_group_id int

(Optional, string) Placement Group ID the server is assigned to.

selector str

Deprecated:

Please use the with_selector property instead.

with_selector str
with_statuses Sequence[str]
backupWindow String

(string) The backup window of the server, if enabled.

backups Boolean

(boolean) Whether backups are enabled.

datacenter String

(string) The datacenter name.

deleteProtection Boolean

(boolean) Whether delete protection is enabled.

firewallIds List<Number>

(Optional, list) Firewall IDs the server is attached to.

id Number

(int) Unique ID of the server.

image String

(string) Name or ID of the image the server was created from.

ipv4Address String

(string) The IPv4 address.

ipv6Address String

(string) The first IPv6 address of the assigned network.

ipv6Network String

(string) The IPv6 network.

iso String

(string) ID or Name of the mounted ISO image.

labels Map<Any>

(map) User-defined labels (key-value pairs)

location String

(string) The location name.

name String

(string) Name of the server.

rebuildProtection Boolean

(boolean) Whether rebuild protection is enabled.

rescue String
serverType String

(string) Name of the server type.

status String

(string) The status of the server.

placementGroupId Number

(Optional, string) Placement Group ID the server is assigned to.

selector String

Deprecated:

Please use the with_selector property instead.

withSelector String
withStatuses List<String>

Package Details

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

This Pulumi package is based on the hcloud Terraform Provider.