UNPKG

@pulumi/gcp

Version:

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

125 lines 5.15 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.AttachedDisk = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = 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}} * ``` * * ```sh * $ 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 }); } /** * 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["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["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; /** @internal */ AttachedDisk.__pulumiType = 'gcp:compute/attachedDisk:AttachedDisk'; //# sourceMappingURL=attachedDisk.js.map