UNPKG

@pulumi/digitalocean

Version:

A Pulumi package for creating and managing DigitalOcean cloud resources.

130 lines 5.67 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Volume = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * Provides a DigitalOcean Block Storage volume which can be attached to a Droplet in order to provide expanded storage. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const foobar = new digitalocean.Volume("foobar", { * region: digitalocean.Region.NYC1, * name: "baz", * size: 100, * initialFilesystemType: digitalocean.FileSystemType.EXT4, * description: "an example volume", * }); * const foobarDroplet = new digitalocean.Droplet("foobar", { * name: "baz", * size: digitalocean.DropletSlug.DropletS1VCPU1GB, * image: "ubuntu-18-04-x64", * region: digitalocean.Region.NYC1, * }); * const foobarVolumeAttachment = new digitalocean.VolumeAttachment("foobar", { * dropletId: foobarDroplet.id, * volumeId: foobar.id, * }); * ``` * * You can also create a volume from an existing snapshot. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as digitalocean from "@pulumi/digitalocean"; * * const foobar = digitalocean.getVolumeSnapshot({ * name: "baz", * }); * const foobarVolume = new digitalocean.Volume("foobar", { * region: digitalocean.Region.LON1, * name: "foo", * size: foobar.then(foobar => foobar.minDiskSize), * snapshotId: foobar.then(foobar => foobar.id), * }); * ``` * * ## Import * * Volumes can be imported using the `volume id`, e.g. * * ```sh * $ pulumi import digitalocean:index/volume:Volume volume 506f78a4-e098-11e5-ad9f-000f53306ae1 * ``` */ class Volume extends pulumi.CustomResource { /** * Get an existing Volume 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 Volume(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Volume. 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'] === Volume.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["dropletIds"] = state ? state.dropletIds : undefined; resourceInputs["filesystemLabel"] = state ? state.filesystemLabel : undefined; resourceInputs["filesystemType"] = state ? state.filesystemType : undefined; resourceInputs["initialFilesystemLabel"] = state ? state.initialFilesystemLabel : undefined; resourceInputs["initialFilesystemType"] = state ? state.initialFilesystemType : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["size"] = state ? state.size : undefined; resourceInputs["snapshotId"] = state ? state.snapshotId : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["volumeUrn"] = state ? state.volumeUrn : undefined; } else { const args = argsOrState; if ((!args || args.region === undefined) && !opts.urn) { throw new Error("Missing required property 'region'"); } if ((!args || args.size === undefined) && !opts.urn) { throw new Error("Missing required property 'size'"); } resourceInputs["description"] = args ? args.description : undefined; resourceInputs["filesystemType"] = args ? args.filesystemType : undefined; resourceInputs["initialFilesystemLabel"] = args ? args.initialFilesystemLabel : undefined; resourceInputs["initialFilesystemType"] = args ? args.initialFilesystemType : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["size"] = args ? args.size : undefined; resourceInputs["snapshotId"] = args ? args.snapshotId : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["dropletIds"] = undefined /*out*/; resourceInputs["filesystemLabel"] = undefined /*out*/; resourceInputs["volumeUrn"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Volume.__pulumiType, name, resourceInputs, opts); } } exports.Volume = Volume; /** @internal */ Volume.__pulumiType = 'digitalocean:index/volume:Volume'; //# sourceMappingURL=volume.js.map