@pulumi/hcloud
Version:
A Pulumi package for creating and managing hcloud cloud resources.
103 lines • 4.08 kB
JavaScript
;
// *** 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.ServerNetwork = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides a Hetzner Cloud Server Network to represent a private network on a server in the Hetzner Cloud.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as hcloud from "@pulumi/hcloud";
*
* const node1 = new hcloud.Server("node1", {
* name: "node1",
* image: "debian-11",
* serverType: "cx22",
* });
* const mynet = new hcloud.Network("mynet", {
* name: "my-net",
* ipRange: "10.0.0.0/8",
* });
* const foonet = new hcloud.NetworkSubnet("foonet", {
* networkId: mynet.id,
* type: "cloud",
* networkZone: "eu-central",
* ipRange: "10.0.1.0/24",
* });
* const srvnetwork = new hcloud.ServerNetwork("srvnetwork", {
* serverId: node1.id,
* networkId: mynet.id,
* ip: "10.0.1.5",
* });
* ```
*
* ## Import
*
* Server Network entries can be imported using a compound ID with the following format:
*
* `<server-id>-<network-id>`
*
* ```sh
* $ pulumi import hcloud:index/serverNetwork:ServerNetwork example "$SERVER_ID-$NETWORK_ID"
* ```
*/
class ServerNetwork extends pulumi.CustomResource {
/**
* Get an existing ServerNetwork 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 ServerNetwork(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of ServerNetwork. 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'] === ServerNetwork.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["aliasIps"] = state ? state.aliasIps : undefined;
resourceInputs["ip"] = state ? state.ip : undefined;
resourceInputs["macAddress"] = state ? state.macAddress : undefined;
resourceInputs["networkId"] = state ? state.networkId : undefined;
resourceInputs["serverId"] = state ? state.serverId : undefined;
resourceInputs["subnetId"] = state ? state.subnetId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.serverId === undefined) && !opts.urn) {
throw new Error("Missing required property 'serverId'");
}
resourceInputs["aliasIps"] = args ? args.aliasIps : undefined;
resourceInputs["ip"] = args ? args.ip : undefined;
resourceInputs["networkId"] = args ? args.networkId : undefined;
resourceInputs["serverId"] = args ? args.serverId : undefined;
resourceInputs["subnetId"] = args ? args.subnetId : undefined;
resourceInputs["macAddress"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ServerNetwork.__pulumiType, name, resourceInputs, opts);
}
}
exports.ServerNetwork = ServerNetwork;
/** @internal */
ServerNetwork.__pulumiType = 'hcloud:index/serverNetwork:ServerNetwork';
//# sourceMappingURL=serverNetwork.js.map