UNPKG

@pulumi/hcloud

Version:

A Pulumi package for creating and managing hcloud cloud resources.

262 lines 10.5 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Server = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * 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.apply(x =>Number(x)), * 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 networkSubnet = new hcloud.NetworkSubnet("network_subnet", { * type: "cloud", * networkId: network.id.apply(x =>Number(x)), * 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: [{ * subnetId: networkSubnet.id, * ip: "10.0.1.5", * aliasIps: [ * "10.0.1.6", * "10.0.1.7", * ], * }], * }); * ``` * * ### 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: output(packerSnapshot.then(packerSnapshot => packerSnapshot.id)).apply(x =>String(x)), * 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" * ``` */ 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, id, state, opts) { return new Server(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'hcloud:index/server: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) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Server.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["allowDeprecatedImages"] = state?.allowDeprecatedImages; resourceInputs["backupWindow"] = state?.backupWindow; resourceInputs["backups"] = state?.backups; resourceInputs["datacenter"] = state?.datacenter; resourceInputs["deleteProtection"] = state?.deleteProtection; resourceInputs["firewallIds"] = state?.firewallIds; resourceInputs["ignoreRemoteFirewallIds"] = state?.ignoreRemoteFirewallIds; resourceInputs["image"] = state?.image; resourceInputs["ipv4Address"] = state?.ipv4Address; resourceInputs["ipv6Address"] = state?.ipv6Address; resourceInputs["ipv6Network"] = state?.ipv6Network; resourceInputs["iso"] = state?.iso; resourceInputs["keepDisk"] = state?.keepDisk; resourceInputs["labels"] = state?.labels; resourceInputs["location"] = state?.location; resourceInputs["name"] = state?.name; resourceInputs["networks"] = state?.networks; resourceInputs["placementGroupId"] = state?.placementGroupId; resourceInputs["primaryDiskSize"] = state?.primaryDiskSize; resourceInputs["publicNets"] = state?.publicNets; resourceInputs["rebuildProtection"] = state?.rebuildProtection; resourceInputs["rescue"] = state?.rescue; resourceInputs["serverType"] = state?.serverType; resourceInputs["shutdownBeforeDeletion"] = state?.shutdownBeforeDeletion; resourceInputs["sshKeys"] = state?.sshKeys; resourceInputs["status"] = state?.status; resourceInputs["userData"] = state?.userData; } else { const args = argsOrState; if (args?.serverType === undefined && !opts.urn) { throw new Error("Missing required property 'serverType'"); } resourceInputs["allowDeprecatedImages"] = args?.allowDeprecatedImages; resourceInputs["backups"] = args?.backups; resourceInputs["datacenter"] = args?.datacenter; resourceInputs["deleteProtection"] = args?.deleteProtection; resourceInputs["firewallIds"] = args?.firewallIds; resourceInputs["ignoreRemoteFirewallIds"] = args?.ignoreRemoteFirewallIds; resourceInputs["image"] = args?.image; resourceInputs["iso"] = args?.iso; resourceInputs["keepDisk"] = args?.keepDisk; resourceInputs["labels"] = args?.labels; resourceInputs["location"] = args?.location; resourceInputs["name"] = args?.name; resourceInputs["networks"] = args?.networks; resourceInputs["placementGroupId"] = args?.placementGroupId; resourceInputs["publicNets"] = args?.publicNets; resourceInputs["rebuildProtection"] = args?.rebuildProtection; resourceInputs["rescue"] = args?.rescue; resourceInputs["serverType"] = args?.serverType; resourceInputs["shutdownBeforeDeletion"] = args?.shutdownBeforeDeletion; resourceInputs["sshKeys"] = args?.sshKeys; resourceInputs["userData"] = args?.userData; resourceInputs["backupWindow"] = undefined /*out*/; resourceInputs["ipv4Address"] = undefined /*out*/; resourceInputs["ipv6Address"] = undefined /*out*/; resourceInputs["ipv6Network"] = undefined /*out*/; resourceInputs["primaryDiskSize"] = undefined /*out*/; resourceInputs["status"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Server.__pulumiType, name, resourceInputs, opts); } } exports.Server = Server; //# sourceMappingURL=server.js.map