google_compute_region_disk

Persistent disks are durable storage devices that function similarly to the physical disks in a desktop or a server. Compute Engine manages the hardware behind these devices to ensure data redundancy and optimize performance for you. Persistent disks are available as either standard hard disk drives (HDD) or solid-state drives (SSD).

Persistent disks are located independently from your virtual machine instances, so you can detach or move persistent disks to keep your data even after you delete your instances. Persistent disk performance scales automatically with size, so you can resize your existing persistent disks or add more persistent disks to an instance to meet your performance and storage space requirements.

Add a persistent disk to your instance when you need reliable and affordable storage with consistent performance characteristics.

To get more information about RegionDisk, see:

Open in Cloud Shell

Example Usage - Region Disk Basic

resource "google_compute_region_disk" "regiondisk" {
  name                      = "my-region-disk"
  snapshot                  = google_compute_snapshot.snapdisk.id
  type                      = "pd-ssd"
  region                    = "us-central1"
  physical_block_size_bytes = 4096

  replica_zones = ["us-central1-a", "us-central1-f"]
}

resource "google_compute_disk" "disk" {
  name  = "my-disk"
  image = "debian-cloud/debian-11"
  size  = 50
  type  = "pd-ssd"
  zone  = "us-central1-a"
}

resource "google_compute_snapshot" "snapdisk" {
  name        = "my-snapshot"
  source_disk = google_compute_disk.disk.name
  zone        = "us-central1-a"
}
Open in Cloud Shell

Example Usage - Region Disk Async

resource "google_compute_region_disk" "primary" {
  name                      = "primary-region-disk"
  type                      = "pd-ssd"
  region                    = "us-central1"
  physical_block_size_bytes = 4096

  replica_zones = ["us-central1-a", "us-central1-f"]
}

resource "google_compute_region_disk" "secondary" {
  name                      = "secondary-region-disk"
  type                      = "pd-ssd"
  region                    = "us-east1"
  physical_block_size_bytes = 4096

  async_primary_disk {
    disk = google_compute_region_disk.primary.id
  }

  replica_zones = ["us-east1-b", "us-east1-c"]
}
Open in Cloud Shell

Example Usage - Region Disk Features

resource "google_compute_region_disk" "regiondisk" {
  name                      = "my-region-features-disk"
  type                      = "pd-ssd"
  region                    = "us-central1"
  physical_block_size_bytes = 4096

  guest_os_features {
    type = "SECURE_BOOT"
  }

  guest_os_features {
    type = "MULTI_IP_SUBNET"
  }

  guest_os_features {
    type = "WINDOWS"
  }

  licenses = ["https://www.googleapis.com/compute/v1/projects/windows-cloud/global/licenses/windows-server-core"]

  replica_zones = ["us-central1-a", "us-central1-f"]
}

Argument Reference

The following arguments are supported:


The async_primary_disk block supports:

The guest_os_features block supports:

The disk_encryption_key block supports:

The source_snapshot_encryption_key block supports:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

RegionDisk can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import RegionDisk using one of the formats above. For example:

import {
  id = "projects/{{project}}/regions/{{region}}/disks/{{name}}"
  to = google_compute_region_disk.default
}

When using the terraform import command, RegionDisk can be imported using one of the formats above. For example:

$ terraform import google_compute_region_disk.default projects/{{project}}/regions/{{region}}/disks/{{name}}
$ terraform import google_compute_region_disk.default {{project}}/{{region}}/{{name}}
$ terraform import google_compute_region_disk.default {{region}}/{{name}}
$ terraform import google_compute_region_disk.default {{name}}

User Project Overrides

This resource supports User Project Overrides.