Expand description
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
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
use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
let default = attached_disk::create(
"default",
AttachedDiskArgs::builder()
.disk("${defaultGoogleComputeDisk.id}")
.instance("${defaultInstance.id}")
.build_struct(),
);
let defaultInstance = instance::create(
"defaultInstance",
InstanceArgs::builder()
.boot_disk(
InstanceBootDisk::builder()
.initializeParams(
InstanceBootDiskInitializeParams::builder()
.image("debian-cloud/debian-11")
.build_struct(),
)
.build_struct(),
)
.machine_type("e2-medium")
.name("attached-disk-instance")
.network_interfaces(
vec![
InstanceNetworkInterface::builder().network("default")
.build_struct(),
],
)
.zone("us-west1-a")
.build_struct(),
);
}
§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:
$ 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}}
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments