Hetzner Cloud v1.20.4 published on Tuesday, Sep 24, 2024 by Pulumi
hcloud.getServer
Explore with Pulumi AI
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",
});
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")
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
})
}
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",
});
});
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());
}
}
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.
- Placement
Group intId - (Optional, string) Placement Group ID the server is assigned to.
- Selector string
- With
Selector string - Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
- With
Statuses 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.
- Placement
Group intId - (Optional, string) Placement Group ID the server is assigned to.
- Selector string
- With
Selector string - Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
- With
Statuses []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.
- placement
Group IntegerId - (Optional, string) Placement Group ID the server is assigned to.
- selector String
- with
Selector String - Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
- with
Statuses 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.
- placement
Group numberId - (Optional, string) Placement Group ID the server is assigned to.
- selector string
- with
Selector string - Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
- with
Statuses 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_ intid - (Optional, string) Placement Group ID the server is assigned to.
- selector str
- 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.
- placement
Group NumberId - (Optional, string) Placement Group ID the server is assigned to.
- selector String
- with
Selector String - Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
- with
Statuses 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:
- Backup
Window string - (string) The backup window of the server, if enabled.
- Backups bool
- (bool) Whether backups are enabled.
- Datacenter string
- (string) The datacenter name.
- Delete
Protection bool - (bool) Whether delete protection is enabled.
- Firewall
Ids 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.
- Name string
- (string) Name of the server.
- Primary
Disk intSize - (int) The size of the primary disk in GB.
- Rebuild
Protection bool - (bool) Whether rebuild protection is enabled.
- Rescue string
- Server
Type string - (string) Name of the server type.
- Status string
- (string) The status of the server.
- Placement
Group intId - (Optional, string) Placement Group ID the server is assigned to.
- Selector string
- With
Selector string - With
Statuses List<string>
- Backup
Window string - (string) The backup window of the server, if enabled.
- Backups bool
- (bool) Whether backups are enabled.
- Datacenter string
- (string) The datacenter name.
- Delete
Protection bool - (bool) Whether delete protection is enabled.
- Firewall
Ids []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.
- Name string
- (string) Name of the server.
- Primary
Disk intSize - (int) The size of the primary disk in GB.
- Rebuild
Protection bool - (bool) Whether rebuild protection is enabled.
- Rescue string
- Server
Type string - (string) Name of the server type.
- Status string
- (string) The status of the server.
- Placement
Group intId - (Optional, string) Placement Group ID the server is assigned to.
- Selector string
- With
Selector string - With
Statuses []string
- backup
Window String - (string) The backup window of the server, if enabled.
- backups Boolean
- (bool) Whether backups are enabled.
- datacenter String
- (string) The datacenter name.
- delete
Protection Boolean - (bool) Whether delete protection is enabled.
- firewall
Ids 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.
- name String
- (string) Name of the server.
- primary
Disk IntegerSize - (int) The size of the primary disk in GB.
- rebuild
Protection Boolean - (bool) Whether rebuild protection is enabled.
- rescue String
- server
Type String - (string) Name of the server type.
- status String
- (string) The status of the server.
- placement
Group IntegerId - (Optional, string) Placement Group ID the server is assigned to.
- selector String
- with
Selector String - with
Statuses List<String>
- backup
Window string - (string) The backup window of the server, if enabled.
- backups boolean
- (bool) Whether backups are enabled.
- datacenter string
- (string) The datacenter name.
- delete
Protection boolean - (bool) Whether delete protection is enabled.
- firewall
Ids 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.
- name string
- (string) Name of the server.
- primary
Disk numberSize - (int) The size of the primary disk in GB.
- rebuild
Protection boolean - (bool) Whether rebuild protection is enabled.
- rescue string
- server
Type string - (string) Name of the server type.
- status string
- (string) The status of the server.
- placement
Group numberId - (Optional, string) Placement Group ID the server is assigned to.
- selector string
- with
Selector string - with
Statuses 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.
- 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.
- name str
- (string) Name of the server.
- primary_
disk_ intsize - (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_ intid - (Optional, string) Placement Group ID the server is assigned to.
- selector str
- with_
selector str - with_
statuses Sequence[str]
- backup
Window String - (string) The backup window of the server, if enabled.
- backups Boolean
- (bool) Whether backups are enabled.
- datacenter String
- (string) The datacenter name.
- delete
Protection Boolean - (bool) Whether delete protection is enabled.
- firewall
Ids 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.
- name String
- (string) Name of the server.
- primary
Disk NumberSize - (int) The size of the primary disk in GB.
- rebuild
Protection Boolean - (bool) Whether rebuild protection is enabled.
- rescue String
- server
Type String - (string) Name of the server type.
- status String
- (string) The status of the server.
- placement
Group NumberId - (Optional, string) Placement Group ID the server is assigned to.
- selector String
- with
Selector String - with
Statuses 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.