AttachedDiskArgs

data class AttachedDiskArgs(val deviceName: Output<String>? = null, val disk: Output<String>? = null, val instance: Output<String>? = null, val mode: Output<String>? = null, val project: Output<String>? = null, val zone: Output<String>? = null) : ConvertibleToJava<AttachedDiskArgs>

Persistent disks can be attached to a compute instance using the attached_disk 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

  • How-to Guides

    • Adding a persistent disk Note: When using gcp.compute.AttachedDisk you must use lifecycle.ignore_changes = ["attached_disk"] 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

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Instance;
import com.pulumi.gcp.compute.InstanceArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
import com.pulumi.gcp.compute.AttachedDisk;
import com.pulumi.gcp.compute.AttachedDiskArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
.machineType("e2-medium")
.zone("us-west1-a")
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image("debian-cloud/debian-11")
.build())
.build())
.networkInterfaces(InstanceNetworkInterfaceArgs.builder()
.network("default")
.build())
.build());
var defaultAttachedDisk = new AttachedDisk("defaultAttachedDisk", AttachedDiskArgs.builder()
.disk(google_compute_disk.default().id())
.instance(defaultInstance.id())
.build());
}
}

Import

Attached Disk can be imported the following ways

$ 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}}

Constructors

Link copied to clipboard
constructor(deviceName: Output<String>? = null, disk: Output<String>? = null, instance: Output<String>? = null, mode: Output<String>? = null, project: Output<String>? = null, zone: Output<String>? = null)

Properties

Link copied to clipboard
val deviceName: Output<String>? = null

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.

Link copied to clipboard
val disk: Output<String>? = null

name or self_link of the disk that will be attached.

Link copied to clipboard
val instance: Output<String>? = null

name or self_link of the compute instance that the disk will be attached to. If the self_link 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.

Link copied to clipboard
val mode: Output<String>? = null

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"

Link copied to clipboard
val project: Output<String>? = null

The project that the referenced compute instance is a part of. If instance is referenced by its self_link the project defined in the link will take precedence.

Link copied to clipboard
val zone: Output<String>? = null

The zone that the referenced compute instance is located within. If instance is referenced by its self_link the zone defined in the link will take precedence.

Functions

Link copied to clipboard
open override fun toJava(): AttachedDiskArgs