UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

146 lines 6.32 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! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AttachedDisk = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Persistent disks can be attached to a compute instance using the `attachedDisk` * section within the compute instance configuration. * However there may be situations where managing the attached disks via the compute * instance config isn't preferable or possible, such as attaching dynamic * numbers of disks using the `count` variable. * * To get more information about attaching disks, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/instances/attachDisk) * * How-to Guides * * [Adding a persistent disk](https://cloud.google.com/compute/docs/disks/add-persistent-disk) * * **Note:** When using `gcp.compute.AttachedDisk` you **must** use `lifecycle.ignore_changes = ["attachedDisk"]` on the `gcp.compute.Instance` resource that has the disks attached. Otherwise the two resources will fight for control of the attached disk block. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultInstance = new gcp.compute.Instance("default", { * name: "attached-disk-instance", * machineType: "e2-medium", * zone: "us-west1-a", * bootDisk: { * initializeParams: { * image: "debian-cloud/debian-11", * }, * }, * networkInterfaces: [{ * network: "default", * }], * }); * const _default = new gcp.compute.AttachedDisk("default", { * disk: defaultGoogleComputeDisk.id, * instance: defaultInstance.id, * }); * ``` * * ## Import * * Attached Disk can be imported the following ways: * * * `projects/{{project}}/zones/{{zone}}/instances/{{instance.name}}/{{disk.name}}` * * `{{project}}/{{zone}}/{{instance.name}}/{{disk.name}}` * * When using the `pulumi import` command, Attached Disk can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/attachedDisk:AttachedDisk default projects/{{project}}/zones/{{zone}}/instances/{{instance.name}}/{{disk.name}} * $ pulumi import gcp:compute/attachedDisk:AttachedDisk default {{project}}/{{zone}}/{{instance.name}}/{{disk.name}} * ``` */ class AttachedDisk extends pulumi.CustomResource { /** * Get an existing AttachedDisk 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 AttachedDisk(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:compute/attachedDisk:AttachedDisk'; /** * Returns true if the given object is an instance of AttachedDisk. 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'] === AttachedDisk.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["deviceName"] = state?.deviceName; resourceInputs["disk"] = state?.disk; resourceInputs["instance"] = state?.instance; resourceInputs["interface"] = state?.interface; resourceInputs["mode"] = state?.mode; resourceInputs["project"] = state?.project; resourceInputs["zone"] = state?.zone; } else { const args = argsOrState; if (args?.disk === undefined && !opts.urn) { throw new Error("Missing required property 'disk'"); } if (args?.instance === undefined && !opts.urn) { throw new Error("Missing required property 'instance'"); } resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["deviceName"] = args?.deviceName; resourceInputs["disk"] = args?.disk; resourceInputs["instance"] = args?.instance; resourceInputs["interface"] = args?.interface; resourceInputs["mode"] = args?.mode; resourceInputs["project"] = args?.project; resourceInputs["zone"] = args?.zone; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(AttachedDisk.__pulumiType, name, resourceInputs, opts); } } exports.AttachedDisk = AttachedDisk; //# sourceMappingURL=attachedDisk.js.map