@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
141 lines • 5.78 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.VolumeAttach = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Attaches a volume to an ECS Instance.
*
* ## Example Usage
* ### Basic attachment of a single volume to a single instance
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const securityGroupId = config.requireObject("securityGroupId");
* const myvol = new huaweicloud.evs.Volume("myvol", {
* availabilityZone: "cn-north-4a",
* volumeType: "SAS",
* size: 10,
* });
* const myinstance = new huaweicloud.ecs.Instance("myinstance", {
* imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
* flavorId: "s6.small.1",
* keyPair: "my_key_pair_name",
* securityGroupIds: [securityGroupId],
* availabilityZone: "cn-north-4a",
* networks: [{
* uuid: "55534eaa-533a-419d-9b40-ec427ea7195a",
* }],
* });
* const attached = new huaweicloud.ecs.VolumeAttach("attached", {
* instanceId: myinstance.id,
* volumeId: myvol.id,
* });
* ```
* ### Attaching multiple volumes to a single instance
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* export = async () => {
* const config = new pulumi.Config();
* const securityGroupId = config.requireObject("securityGroupId");
* const myvol: huaweicloud.evs.Volume[];
* for (const range = {value: 0}; range.value < 2; range.value++) {
* myvol.push(new huaweicloud.evs.Volume(`myvol-${range.value}`, {
* availabilityZone: "cn-north-4a",
* volumeType: "SAS",
* size: 10,
* }));
* }
* const myinstance = new huaweicloud.ecs.Instance("myinstance", {
* imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
* flavorId: "s6.small.1",
* keyPair: "my_key_pair_name",
* securityGroupIds: [securityGroupId],
* availabilityZone: "cn-north-4a",
* });
* const attachments: huaweicloud.ecs.VolumeAttach[];
* for (const range = {value: 0}; range.value < 2; range.value++) {
* attachments.push(new huaweicloud.ecs.VolumeAttach(`attachments-${range.value}`, {
* instanceId: myinstance.id,
* volumeId: myvol.map(__item => __item.id)[range.value],
* }));
* }
* const volume_devices = attachments.map(__item => __item.device);
* return {
* "volume devices": volume_devices,
* };
* }
* ```
*
* ## Import
*
* Volume Attachments can be imported using the Instance ID and Volume ID separated by a slash, e.g.
*
* ```sh
* $ pulumi import huaweicloud:Ecs/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["pciAddress"] = state ? state.pciAddress : undefined;
resourceInputs["region"] = state ? state.region : 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["region"] = args ? args.region : undefined;
resourceInputs["volumeId"] = args ? args.volumeId : undefined;
resourceInputs["pciAddress"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(VolumeAttach.__pulumiType, name, resourceInputs, opts);
}
}
exports.VolumeAttach = VolumeAttach;
/** @internal */
VolumeAttach.__pulumiType = 'huaweicloud:Ecs/volumeAttach:VolumeAttach';
//# sourceMappingURL=volumeAttach.js.map