1. Packages
  2. Hcloud Provider
  3. API Docs
  4. getServer
Hetzner Cloud v1.22.1 published on Friday, Apr 25, 2025 by Pulumi

hcloud.getServer

Explore with Pulumi AI

Hetzner Cloud v1.22.1 published on Friday, Apr 25, 2025 by Pulumi

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const s1 = hcloud.getServer({
    name: "my-server",
});
const s2 = hcloud.getServer({
    id: 123,
});
const s3 = hcloud.getServer({
    withSelector: "key=value",
});
Copy
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")
Copy
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, &hcloud.LookupServerArgs{
			Name: pulumi.StringRef("my-server"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = hcloud.LookupServer(ctx, &hcloud.LookupServerArgs{
			Id: pulumi.IntRef(123),
		}, nil)
		if err != nil {
			return err
		}
		_, err = hcloud.LookupServer(ctx, &hcloud.LookupServerArgs{
			WithSelector: pulumi.StringRef("key=value"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;

return await Deployment.RunAsync(() => 
{
    var s1 = HCloud.GetServer.Invoke(new()
    {
        Name = "my-server",
    });

    var s2 = HCloud.GetServer.Invoke(new()
    {
        Id = 123,
    });

    var s3 = HCloud.GetServer.Invoke(new()
    {
        WithSelector = "key=value",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.HcloudFunctions;
import com.pulumi.hcloud.inputs.GetServerArgs;
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) {
        final var s1 = HcloudFunctions.getServer(GetServerArgs.builder()
            .name("my-server")
            .build());

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

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

    }
}
Copy
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
Copy

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>
Copy
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]
Copy
func LookupServer(ctx *Context, args *LookupServerArgs, opts ...InvokeOption) (*LookupServerResult, error)
func LookupServerOutput(ctx *Context, args *LookupServerOutputArgs, opts ...InvokeOption) LookupServerResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetServerResult> getServer(GetServerArgs args, InvokeOptions options)
public static Output<GetServerResult> getServer(GetServerArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: hcloud:index/getServer:getServer
  arguments:
    # arguments dictionary
Copy

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
(bool) Whether backups are enabled.
Datacenter string
(string) The datacenter name. See the Hetzner Docs for more details about datacenters.
DeleteProtection bool
(bool) 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. Architecture of ISO must equal the server (type) architecture.
Labels Dictionary<string, string>
(map) User-defined labels (key-value pairs)
Location string
(string) The location name. See the Hetzner Docs for more details about locations.
Name string
(string) Name of the server.
PrimaryDiskSize int
(int) The size of the primary disk in GB.
RebuildProtection bool
(bool) 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
(bool) Whether backups are enabled.
Datacenter string
(string) The datacenter name. See the Hetzner Docs for more details about datacenters.
DeleteProtection bool
(bool) 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. Architecture of ISO must equal the server (type) architecture.
Labels map[string]string
(map) User-defined labels (key-value pairs)
Location string
(string) The location name. See the Hetzner Docs for more details about locations.
Name string
(string) Name of the server.
PrimaryDiskSize int
(int) The size of the primary disk in GB.
RebuildProtection bool
(bool) 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
(bool) Whether backups are enabled.
datacenter String
(string) The datacenter name. See the Hetzner Docs for more details about datacenters.
deleteProtection Boolean
(bool) 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. Architecture of ISO must equal the server (type) architecture.
labels Map<String,String>
(map) User-defined labels (key-value pairs)
location String
(string) The location name. See the Hetzner Docs for more details about locations.
name String
(string) Name of the server.
primaryDiskSize Integer
(int) The size of the primary disk in GB.
rebuildProtection Boolean
(bool) 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
(bool) Whether backups are enabled.
datacenter string
(string) The datacenter name. See the Hetzner Docs for more details about datacenters.
deleteProtection boolean
(bool) 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. Architecture of ISO must equal the server (type) architecture.
labels {[key: string]: string}
(map) User-defined labels (key-value pairs)
location string
(string) The location name. See the Hetzner Docs for more details about locations.
name string
(string) Name of the server.
primaryDiskSize number
(int) The size of the primary disk in GB.
rebuildProtection boolean
(bool) 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
(bool) Whether backups are enabled.
datacenter str
(string) The datacenter name. See the Hetzner Docs for more details about datacenters.
delete_protection bool
(bool) 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. Architecture of ISO must equal the server (type) architecture.
labels Mapping[str, str]
(map) User-defined labels (key-value pairs)
location str
(string) The location name. See the Hetzner Docs for more details about locations.
name str
(string) Name of the server.
primary_disk_size int
(int) The size of the primary disk in GB.
rebuild_protection bool
(bool) 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
(bool) Whether backups are enabled.
datacenter String
(string) The datacenter name. See the Hetzner Docs for more details about datacenters.
deleteProtection Boolean
(bool) 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. Architecture of ISO must equal the server (type) architecture.
labels Map<String>
(map) User-defined labels (key-value pairs)
location String
(string) The location name. See the Hetzner Docs for more details about locations.
name String
(string) Name of the server.
primaryDiskSize Number
(int) The size of the primary disk in GB.
rebuildProtection Boolean
(bool) 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
Hetzner Cloud pulumi/pulumi-hcloud
License
Apache-2.0
Notes
This Pulumi package is based on the hcloud Terraform Provider.
Hetzner Cloud v1.22.1 published on Friday, Apr 25, 2025 by Pulumi