UNPKG

@pulumi/hcloud

Version:

A Pulumi package for creating and managing hcloud cloud resources.

228 lines 9.71 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Server = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * Provides an Hetzner Cloud server resource. This can be used to create, modify, and delete servers. Servers also support provisioning. * * ## 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-11", * serverType: "cx22", * 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", * datacenter: "fsn1-dc14", * type: "ipv4", * assigneeType: "server", * autoDelete: true, * labels: { * hallo: "welt", * }, * }); * const serverTest = new hcloud.Server("server_test", { * name: "test-server", * image: "ubuntu-20.04", * serverType: "cx22", * datacenter: "fsn1-dc14", * 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: "cx22", * image: "ubuntu-20.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: "cx22", * 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, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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 ? state.allowDeprecatedImages : undefined; resourceInputs["backupWindow"] = state ? state.backupWindow : undefined; resourceInputs["backups"] = state ? state.backups : undefined; resourceInputs["datacenter"] = state ? state.datacenter : undefined; resourceInputs["deleteProtection"] = state ? state.deleteProtection : undefined; resourceInputs["firewallIds"] = state ? state.firewallIds : undefined; resourceInputs["ignoreRemoteFirewallIds"] = state ? state.ignoreRemoteFirewallIds : undefined; resourceInputs["image"] = state ? state.image : undefined; resourceInputs["ipv4Address"] = state ? state.ipv4Address : undefined; resourceInputs["ipv6Address"] = state ? state.ipv6Address : undefined; resourceInputs["ipv6Network"] = state ? state.ipv6Network : undefined; resourceInputs["iso"] = state ? state.iso : undefined; resourceInputs["keepDisk"] = state ? state.keepDisk : undefined; resourceInputs["labels"] = state ? state.labels : undefined; resourceInputs["location"] = state ? state.location : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["networks"] = state ? state.networks : undefined; resourceInputs["placementGroupId"] = state ? state.placementGroupId : undefined; resourceInputs["primaryDiskSize"] = state ? state.primaryDiskSize : undefined; resourceInputs["publicNets"] = state ? state.publicNets : undefined; resourceInputs["rebuildProtection"] = state ? state.rebuildProtection : undefined; resourceInputs["rescue"] = state ? state.rescue : undefined; resourceInputs["serverType"] = state ? state.serverType : undefined; resourceInputs["shutdownBeforeDeletion"] = state ? state.shutdownBeforeDeletion : undefined; resourceInputs["sshKeys"] = state ? state.sshKeys : undefined; resourceInputs["status"] = state ? state.status : undefined; resourceInputs["userData"] = state ? state.userData : undefined; } else { const args = argsOrState; if ((!args || args.serverType === undefined) && !opts.urn) { throw new Error("Missing required property 'serverType'"); } resourceInputs["allowDeprecatedImages"] = args ? args.allowDeprecatedImages : undefined; resourceInputs["backups"] = args ? args.backups : undefined; resourceInputs["datacenter"] = args ? args.datacenter : undefined; resourceInputs["deleteProtection"] = args ? args.deleteProtection : undefined; resourceInputs["firewallIds"] = args ? args.firewallIds : undefined; resourceInputs["ignoreRemoteFirewallIds"] = args ? args.ignoreRemoteFirewallIds : undefined; resourceInputs["image"] = args ? args.image : undefined; resourceInputs["iso"] = args ? args.iso : undefined; resourceInputs["keepDisk"] = args ? args.keepDisk : undefined; resourceInputs["labels"] = args ? args.labels : undefined; resourceInputs["location"] = args ? args.location : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["networks"] = args ? args.networks : undefined; resourceInputs["placementGroupId"] = args ? args.placementGroupId : undefined; resourceInputs["publicNets"] = args ? args.publicNets : undefined; resourceInputs["rebuildProtection"] = args ? args.rebuildProtection : undefined; resourceInputs["rescue"] = args ? args.rescue : undefined; resourceInputs["serverType"] = args ? args.serverType : undefined; resourceInputs["shutdownBeforeDeletion"] = args ? args.shutdownBeforeDeletion : undefined; resourceInputs["sshKeys"] = args ? args.sshKeys : undefined; resourceInputs["userData"] = args ? args.userData : undefined; 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; /** @internal */ Server.__pulumiType = 'hcloud:index/server:Server'; //# sourceMappingURL=server.js.map