import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; /** * Provides an Hetzner Cloud server resource. This can be used to create, modify, and delete servers. Servers also support provisioning. * * ## Deprecations * * ### `datacenter` attribute * * The `datacenter` attribute is deprecated, use the `location` attribute instead. * * See our the [API changelog](https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters) for more details. * * > Please upgrade to `v1.58.0+` of the provider to avoid issues once the Hetzner Cloud API no longer accepts * and returns the `datacenter` attribute. This version of the provider remains backward compatible by preserving * the `datacenter` value in the state and by extracting the `location` name from the `datacenter` attribute when * communicating with the API. * * ## Example Usage * * ### Basic server creation * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as hcloud from "@pulumi/hcloud"; * * // Create a new server running debian * const node1 = new hcloud.Server("node1", { * name: "node1", * image: "debian-12", * serverType: "cx23", * publicNets: [{ * ipv4Enabled: true, * ipv6Enabled: true, * }], * }); * ``` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as hcloud from "@pulumi/hcloud"; * * //## Server creation with one linked primary ip (ipv4) * const primaryIp1 = new hcloud.PrimaryIp("primary_ip_1", { * name: "primary_ip_test", * location: "hel1", * type: "ipv4", * assigneeType: "server", * autoDelete: true, * labels: { * hallo: "welt", * }, * }); * const serverTest = new hcloud.Server("server_test", { * name: "test-server", * image: "ubuntu-24.04", * serverType: "cx23", * location: "hel1", * labels: { * test: "tessst1", * }, * publicNets: [{ * ipv4Enabled: true, * ipv4: primaryIp1.id, * ipv6Enabled: false, * }], * }); * ``` * * ### Server creation with network * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as hcloud from "@pulumi/hcloud"; * * const network = new hcloud.Network("network", { * name: "network", * ipRange: "10.0.0.0/16", * }); * const network_subnet = new hcloud.NetworkSubnet("network-subnet", { * type: "cloud", * networkId: network.id, * networkZone: "eu-central", * ipRange: "10.0.1.0/24", * }); * const server = new hcloud.Server("server", { * name: "server", * serverType: "cx23", * image: "ubuntu-24.04", * location: "nbg1", * networks: [{ * networkId: network.id, * ip: "10.0.1.5", * aliasIps: [ * "10.0.1.6", * "10.0.1.7", * ], * }], * }, { * dependsOn: [network_subnet], * }); * ``` * * ### Server creation from snapshot * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as hcloud from "@pulumi/hcloud"; * * // Get image infos because we need the ID * const packerSnapshot = hcloud.getImage({ * withSelector: "app=foobar", * mostRecent: true, * }); * // Create a new server from the snapshot * const fromSnapshot = new hcloud.Server("from_snapshot", { * name: "from-snapshot", * image: packerSnapshot.then(packerSnapshot => packerSnapshot.id), * serverType: "cx23", * publicNets: [{ * ipv4Enabled: true, * ipv6Enabled: true, * }], * }); * ``` * * ## Primary IPs * * When creating a server without linking at least one ´primary_ip´, it automatically creates & assigns two (ipv4 & ipv6). * With the publicNet block, you can enable or link primary ips. If you don't define this block, two primary ips (ipv4, ipv6) will be created and assigned to the server automatically. * * ## Import * * Servers can be imported using the server `id`: * * ```sh * $ pulumi import hcloud:index/server:Server example "$SERVER_ID" * ``` */ export declare class Server extends pulumi.CustomResource { /** * Get an existing Server resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: ServerState, opts?: pulumi.CustomResourceOptions): Server; /** * Returns true if the given object is an instance of Server. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Server; /** * Enable the use of deprecated images (default: false). **Note** Deprecated images will be removed after three months. Using them is then no longer possible. */ readonly allowDeprecatedImages: pulumi.Output; /** * (string) The backup window of the server, if enabled. * * @deprecated You should remove this property from your terraform configuration. */ readonly backupWindow: pulumi.Output; /** * Enable or disable backups. */ readonly backups: pulumi.Output; /** * The datacenter name to create the server in. See the [Hetzner Docs](https://docs.hetzner.com/cloud/general/locations/#what-datacenters-are-there) for more details about datacenters. * * @deprecated The datacenter attribute is deprecated and will be removed after 1 July 2026. Please use the location attribute instead. See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters. */ readonly datacenter: pulumi.Output; /** * Enable or disable delete protection (Needs to be the same as `rebuildProtection`). See "Delete Protection" in the Provider Docs for details. */ readonly deleteProtection: pulumi.Output; /** * Firewall IDs the server should be attached to on creation. */ readonly firewallIds: pulumi.Output; /** * Ignores any updates * to the `firewallIds` argument which were received from the server. * This should not be used in normal cases. See the documentation of the * `hcloud.FirewallAttachment` resource for a reason to use this * argument. */ readonly ignoreRemoteFirewallIds: pulumi.Output; /** * Name or ID of the image the server is created from. **Note** the `image` property is only required when using the resource to create servers. As the Hetzner Cloud API may return servers without an image ID set it is not marked as required in the Terraform Provider itself. Thus, users will get an error from the underlying client library if they forget to set the property and try to create a server. */ readonly image: pulumi.Output; /** * (string) The IPv4 address. */ readonly ipv4Address: pulumi.Output; /** * (string) The first IPv6 address of the assigned network. */ readonly ipv6Address: pulumi.Output; /** * (string) The IPv6 network. */ readonly ipv6Network: pulumi.Output; /** * ID or Name of an ISO image to mount. */ readonly iso: pulumi.Output; /** * If true, do not upgrade the disk. This allows downgrading the server type later. */ readonly keepDisk: pulumi.Output; /** * User-defined labels (key-value pairs) should be created with. */ readonly labels: pulumi.Output<{ [key: string]: string; } | undefined>; /** * The location name to create the server in. See the [Hetzner Docs](https://docs.hetzner.com/cloud/general/locations/#what-locations-are-there) for more details about locations. */ readonly location: pulumi.Output; /** * Name of the server to create (must be unique per project and a valid hostname as per RFC 1123). */ readonly name: pulumi.Output; /** * Network the server should be attached to on creation. (Can be specified multiple times) */ readonly networks: pulumi.Output; /** * Placement Group ID the server added to on creation. */ readonly placementGroupId: pulumi.Output; /** * (int) The size of the primary disk in GB. */ readonly primaryDiskSize: pulumi.Output; /** * In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). * If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated. */ readonly publicNets: pulumi.Output; /** * Enable or disable rebuild protection (Needs to be the same as `deleteProtection`). */ readonly rebuildProtection: pulumi.Output; /** * Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. `linux64` or `linux32` */ readonly rescue: pulumi.Output; /** * Name of the server type this server should be created with. */ readonly serverType: pulumi.Output; /** * Whether to try shutting the server down gracefully before deleting it. */ readonly shutdownBeforeDeletion: pulumi.Output; /** * SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to `[ sshKeys ]`. */ readonly sshKeys: pulumi.Output; /** * (string) The status of the server. */ readonly status: pulumi.Output; /** * Cloud-Init user data to use during server creation */ readonly userData: pulumi.Output; /** * Create a Server resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ServerArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Server resources. */ export interface ServerState { /** * Enable the use of deprecated images (default: false). **Note** Deprecated images will be removed after three months. Using them is then no longer possible. */ allowDeprecatedImages?: pulumi.Input; /** * (string) The backup window of the server, if enabled. * * @deprecated You should remove this property from your terraform configuration. */ backupWindow?: pulumi.Input; /** * Enable or disable backups. */ backups?: pulumi.Input; /** * The datacenter name to create the server in. See the [Hetzner Docs](https://docs.hetzner.com/cloud/general/locations/#what-datacenters-are-there) for more details about datacenters. * * @deprecated The datacenter attribute is deprecated and will be removed after 1 July 2026. Please use the location attribute instead. See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters. */ datacenter?: pulumi.Input; /** * Enable or disable delete protection (Needs to be the same as `rebuildProtection`). See "Delete Protection" in the Provider Docs for details. */ deleteProtection?: pulumi.Input; /** * Firewall IDs the server should be attached to on creation. */ firewallIds?: pulumi.Input[]>; /** * Ignores any updates * to the `firewallIds` argument which were received from the server. * This should not be used in normal cases. See the documentation of the * `hcloud.FirewallAttachment` resource for a reason to use this * argument. */ ignoreRemoteFirewallIds?: pulumi.Input; /** * Name or ID of the image the server is created from. **Note** the `image` property is only required when using the resource to create servers. As the Hetzner Cloud API may return servers without an image ID set it is not marked as required in the Terraform Provider itself. Thus, users will get an error from the underlying client library if they forget to set the property and try to create a server. */ image?: pulumi.Input; /** * (string) The IPv4 address. */ ipv4Address?: pulumi.Input; /** * (string) The first IPv6 address of the assigned network. */ ipv6Address?: pulumi.Input; /** * (string) The IPv6 network. */ ipv6Network?: pulumi.Input; /** * ID or Name of an ISO image to mount. */ iso?: pulumi.Input; /** * If true, do not upgrade the disk. This allows downgrading the server type later. */ keepDisk?: pulumi.Input; /** * User-defined labels (key-value pairs) should be created with. */ labels?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * The location name to create the server in. See the [Hetzner Docs](https://docs.hetzner.com/cloud/general/locations/#what-locations-are-there) for more details about locations. */ location?: pulumi.Input; /** * Name of the server to create (must be unique per project and a valid hostname as per RFC 1123). */ name?: pulumi.Input; /** * Network the server should be attached to on creation. (Can be specified multiple times) */ networks?: pulumi.Input[]>; /** * Placement Group ID the server added to on creation. */ placementGroupId?: pulumi.Input; /** * (int) The size of the primary disk in GB. */ primaryDiskSize?: pulumi.Input; /** * In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). * If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated. */ publicNets?: pulumi.Input[]>; /** * Enable or disable rebuild protection (Needs to be the same as `deleteProtection`). */ rebuildProtection?: pulumi.Input; /** * Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. `linux64` or `linux32` */ rescue?: pulumi.Input; /** * Name of the server type this server should be created with. */ serverType?: pulumi.Input; /** * Whether to try shutting the server down gracefully before deleting it. */ shutdownBeforeDeletion?: pulumi.Input; /** * SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to `[ sshKeys ]`. */ sshKeys?: pulumi.Input[]>; /** * (string) The status of the server. */ status?: pulumi.Input; /** * Cloud-Init user data to use during server creation */ userData?: pulumi.Input; } /** * The set of arguments for constructing a Server resource. */ export interface ServerArgs { /** * Enable the use of deprecated images (default: false). **Note** Deprecated images will be removed after three months. Using them is then no longer possible. */ allowDeprecatedImages?: pulumi.Input; /** * Enable or disable backups. */ backups?: pulumi.Input; /** * The datacenter name to create the server in. See the [Hetzner Docs](https://docs.hetzner.com/cloud/general/locations/#what-datacenters-are-there) for more details about datacenters. * * @deprecated The datacenter attribute is deprecated and will be removed after 1 July 2026. Please use the location attribute instead. See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters. */ datacenter?: pulumi.Input; /** * Enable or disable delete protection (Needs to be the same as `rebuildProtection`). See "Delete Protection" in the Provider Docs for details. */ deleteProtection?: pulumi.Input; /** * Firewall IDs the server should be attached to on creation. */ firewallIds?: pulumi.Input[]>; /** * Ignores any updates * to the `firewallIds` argument which were received from the server. * This should not be used in normal cases. See the documentation of the * `hcloud.FirewallAttachment` resource for a reason to use this * argument. */ ignoreRemoteFirewallIds?: pulumi.Input; /** * Name or ID of the image the server is created from. **Note** the `image` property is only required when using the resource to create servers. As the Hetzner Cloud API may return servers without an image ID set it is not marked as required in the Terraform Provider itself. Thus, users will get an error from the underlying client library if they forget to set the property and try to create a server. */ image?: pulumi.Input; /** * ID or Name of an ISO image to mount. */ iso?: pulumi.Input; /** * If true, do not upgrade the disk. This allows downgrading the server type later. */ keepDisk?: pulumi.Input; /** * User-defined labels (key-value pairs) should be created with. */ labels?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * The location name to create the server in. See the [Hetzner Docs](https://docs.hetzner.com/cloud/general/locations/#what-locations-are-there) for more details about locations. */ location?: pulumi.Input; /** * Name of the server to create (must be unique per project and a valid hostname as per RFC 1123). */ name?: pulumi.Input; /** * Network the server should be attached to on creation. (Can be specified multiple times) */ networks?: pulumi.Input[]>; /** * Placement Group ID the server added to on creation. */ placementGroupId?: pulumi.Input; /** * In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). * If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated. */ publicNets?: pulumi.Input[]>; /** * Enable or disable rebuild protection (Needs to be the same as `deleteProtection`). */ rebuildProtection?: pulumi.Input; /** * Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. `linux64` or `linux32` */ rescue?: pulumi.Input; /** * Name of the server type this server should be created with. */ serverType: pulumi.Input; /** * Whether to try shutting the server down gracefully before deleting it. */ shutdownBeforeDeletion?: pulumi.Input; /** * SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to `[ sshKeys ]`. */ sshKeys?: pulumi.Input[]>; /** * Cloud-Init user data to use during server creation */ userData?: pulumi.Input; }