UNPKG

@pulumi/gcp

Version:

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

269 lines (268 loc) • 10.4 kB
import * as pulumi from "@pulumi/pulumi"; /** * 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}} * ``` */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: AttachedDiskState, opts?: pulumi.CustomResourceOptions): 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: any): obj is AttachedDisk; /** * Specifies a unique device name of your choice that is * reflected into the /dev/disk/by-id/google-* tree of a Linux operating * system running within the instance. This name can be used to * reference the device for mounting, resizing, and so on, from within * the instance. * * If not specified, the server chooses a default device name to apply * to this disk, in the form persistent-disks-x, where x is a number * assigned by Google Compute Engine. */ readonly deviceName: pulumi.Output<string>; /** * `name` or `selfLink` of the disk that will be attached. * * * - - - */ readonly disk: pulumi.Output<string>; /** * `name` or `selfLink` of the compute instance that the disk will be attached to. * If the `selfLink` is provided then `zone` and `project` are extracted from the * self link. If only the name is used then `zone` and `project` must be defined * as properties on the resource or provider. */ readonly instance: pulumi.Output<string>; /** * The disk interface used for attaching this disk. * * This field is only used for specific cases, please don't specify * this field without advice from Google. Not specifying the field * will allow the the server to assign the correct interface. * * Possible values: * "SCSI" * "NVME" */ readonly interface: pulumi.Output<string | undefined>; /** * The mode in which to attach this disk, either READ_WRITE or * READ_ONLY. If not specified, the default is to attach the disk in * READ_WRITE mode. * * Possible values: * "READ_ONLY" * "READ_WRITE" */ readonly mode: pulumi.Output<string | undefined>; /** * The project that the referenced compute instance is a part of. If `instance` is referenced by its * `selfLink` the project defined in the link will take precedence. */ readonly project: pulumi.Output<string>; /** * The zone that the referenced compute instance is located within. If `instance` is referenced by its * `selfLink` the zone defined in the link will take precedence. */ readonly zone: pulumi.Output<string>; /** * Create a AttachedDisk resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: AttachedDiskArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering AttachedDisk resources. */ export interface AttachedDiskState { /** * Specifies a unique device name of your choice that is * reflected into the /dev/disk/by-id/google-* tree of a Linux operating * system running within the instance. This name can be used to * reference the device for mounting, resizing, and so on, from within * the instance. * * If not specified, the server chooses a default device name to apply * to this disk, in the form persistent-disks-x, where x is a number * assigned by Google Compute Engine. */ deviceName?: pulumi.Input<string>; /** * `name` or `selfLink` of the disk that will be attached. * * * - - - */ disk?: pulumi.Input<string>; /** * `name` or `selfLink` of the compute instance that the disk will be attached to. * If the `selfLink` is provided then `zone` and `project` are extracted from the * self link. If only the name is used then `zone` and `project` must be defined * as properties on the resource or provider. */ instance?: pulumi.Input<string>; /** * The disk interface used for attaching this disk. * * This field is only used for specific cases, please don't specify * this field without advice from Google. Not specifying the field * will allow the the server to assign the correct interface. * * Possible values: * "SCSI" * "NVME" */ interface?: pulumi.Input<string>; /** * The mode in which to attach this disk, either READ_WRITE or * READ_ONLY. If not specified, the default is to attach the disk in * READ_WRITE mode. * * Possible values: * "READ_ONLY" * "READ_WRITE" */ mode?: pulumi.Input<string>; /** * The project that the referenced compute instance is a part of. If `instance` is referenced by its * `selfLink` the project defined in the link will take precedence. */ project?: pulumi.Input<string>; /** * The zone that the referenced compute instance is located within. If `instance` is referenced by its * `selfLink` the zone defined in the link will take precedence. */ zone?: pulumi.Input<string>; } /** * The set of arguments for constructing a AttachedDisk resource. */ export interface AttachedDiskArgs { /** * Specifies a unique device name of your choice that is * reflected into the /dev/disk/by-id/google-* tree of a Linux operating * system running within the instance. This name can be used to * reference the device for mounting, resizing, and so on, from within * the instance. * * If not specified, the server chooses a default device name to apply * to this disk, in the form persistent-disks-x, where x is a number * assigned by Google Compute Engine. */ deviceName?: pulumi.Input<string>; /** * `name` or `selfLink` of the disk that will be attached. * * * - - - */ disk: pulumi.Input<string>; /** * `name` or `selfLink` of the compute instance that the disk will be attached to. * If the `selfLink` is provided then `zone` and `project` are extracted from the * self link. If only the name is used then `zone` and `project` must be defined * as properties on the resource or provider. */ instance: pulumi.Input<string>; /** * The disk interface used for attaching this disk. * * This field is only used for specific cases, please don't specify * this field without advice from Google. Not specifying the field * will allow the the server to assign the correct interface. * * Possible values: * "SCSI" * "NVME" */ interface?: pulumi.Input<string>; /** * The mode in which to attach this disk, either READ_WRITE or * READ_ONLY. If not specified, the default is to attach the disk in * READ_WRITE mode. * * Possible values: * "READ_ONLY" * "READ_WRITE" */ mode?: pulumi.Input<string>; /** * The project that the referenced compute instance is a part of. If `instance` is referenced by its * `selfLink` the project defined in the link will take precedence. */ project?: pulumi.Input<string>; /** * The zone that the referenced compute instance is located within. If `instance` is referenced by its * `selfLink` the zone defined in the link will take precedence. */ zone?: pulumi.Input<string>; }