@pulumi/digitalocean
Version:
A Pulumi package for creating and managing DigitalOcean cloud resources.
130 lines • 5.23 kB
JavaScript
;
// *** 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, { ...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?.description;
resourceInputs["dropletIds"] = state?.dropletIds;
resourceInputs["filesystemLabel"] = state?.filesystemLabel;
resourceInputs["filesystemType"] = state?.filesystemType;
resourceInputs["initialFilesystemLabel"] = state?.initialFilesystemLabel;
resourceInputs["initialFilesystemType"] = state?.initialFilesystemType;
resourceInputs["name"] = state?.name;
resourceInputs["region"] = state?.region;
resourceInputs["size"] = state?.size;
resourceInputs["snapshotId"] = state?.snapshotId;
resourceInputs["tags"] = state?.tags;
resourceInputs["volumeUrn"] = state?.volumeUrn;
}
else {
const args = argsOrState;
if (args?.region === undefined && !opts.urn) {
throw new Error("Missing required property 'region'");
}
if (args?.size === undefined && !opts.urn) {
throw new Error("Missing required property 'size'");
}
resourceInputs["description"] = args?.description;
resourceInputs["filesystemType"] = args?.filesystemType;
resourceInputs["initialFilesystemLabel"] = args?.initialFilesystemLabel;
resourceInputs["initialFilesystemType"] = args?.initialFilesystemType;
resourceInputs["name"] = args?.name;
resourceInputs["region"] = args?.region;
resourceInputs["size"] = args?.size;
resourceInputs["snapshotId"] = args?.snapshotId;
resourceInputs["tags"] = args?.tags;
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