UNPKG

@pulumi/openstack

Version:

A Pulumi package for creating and managing OpenStack cloud resources.

141 lines 5.66 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.VolumeAttach = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Attaches a Block Storage Volume to an Instance using the OpenStack * Compute (Nova) v2 API. * * ## Example Usage * * ### Basic attachment of a single volume to a single instance * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as openstack from "@pulumi/openstack"; * * const volume1 = new openstack.blockstorage.Volume("volume_1", { * name: "volume_1", * size: 1, * }); * const instance1 = new openstack.compute.Instance("instance_1", { * name: "instance_1", * securityGroups: ["default"], * }); * const va1 = new openstack.compute.VolumeAttach("va_1", { * instanceId: instance1.id, * volumeId: volume1.id, * }); * ``` * * ### Using Multiattach-enabled volumes * * Multiattach Volumes are dependent upon your OpenStack cloud and not all * clouds support multiattach. Multiattach volumes require a volumeType that has [multiattach enabled](https://docs.openstack.org/cinder/latest/admin/volume-multiattach.html#multiattach-volume-type). * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as openstack from "@pulumi/openstack"; * * const volume1 = new openstack.blockstorage.Volume("volume_1", { * name: "volume_1", * size: 1, * volumeType: "multiattach", * }); * const instance1 = new openstack.compute.Instance("instance_1", { * name: "instance_1", * securityGroups: ["default"], * }); * const instance2 = new openstack.compute.Instance("instance_2", { * name: "instance_2", * securityGroups: ["default"], * }); * const va1 = new openstack.compute.VolumeAttach("va_1", { * instanceId: instance1.id, * volumeId: volume1.id, * multiattach: true, * }); * const va2 = new openstack.compute.VolumeAttach("va_2", { * instanceId: instance2.id, * volumeId: volume1.id, * multiattach: true, * }, { * dependsOn: [va1], * }); * ``` * * It is recommended to use `dependsOn` for the attach resources * to enforce the volume attachments to happen one at a time. * * ## Import * * Volume Attachments can be imported using the Instance ID and Volume ID * separated by a slash, e.g. * * ```sh * $ pulumi import openstack:compute/volumeAttach:VolumeAttach va_1 89c60255-9bd6-460c-822a-e2b959ede9d2/45670584-225f-46c3-b33e-6707b589b666 * ``` */ class VolumeAttach extends pulumi.CustomResource { /** * Get an existing VolumeAttach 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 VolumeAttach(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of VolumeAttach. 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'] === VolumeAttach.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["device"] = state ? state.device : undefined; resourceInputs["instanceId"] = state ? state.instanceId : undefined; resourceInputs["multiattach"] = state ? state.multiattach : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["tag"] = state ? state.tag : undefined; resourceInputs["vendorOptions"] = state ? state.vendorOptions : undefined; resourceInputs["volumeId"] = state ? state.volumeId : undefined; } else { const args = argsOrState; if ((!args || args.instanceId === undefined) && !opts.urn) { throw new Error("Missing required property 'instanceId'"); } if ((!args || args.volumeId === undefined) && !opts.urn) { throw new Error("Missing required property 'volumeId'"); } resourceInputs["device"] = args ? args.device : undefined; resourceInputs["instanceId"] = args ? args.instanceId : undefined; resourceInputs["multiattach"] = args ? args.multiattach : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["tag"] = args ? args.tag : undefined; resourceInputs["vendorOptions"] = args ? args.vendorOptions : undefined; resourceInputs["volumeId"] = args ? args.volumeId : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(VolumeAttach.__pulumiType, name, resourceInputs, opts); } } exports.VolumeAttach = VolumeAttach; /** @internal */ VolumeAttach.__pulumiType = 'openstack:compute/volumeAttach:VolumeAttach'; //# sourceMappingURL=volumeAttach.js.map