» google_compute_region_disk_resource_policy_attachment

Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.

» Example Usage - Region Disk Resource Policy Attachment Basic

resource "google_compute_region_disk_resource_policy_attachment" "attachment" {
  name = google_compute_resource_policy.policy.name
  disk = google_compute_region_disk.ssd.name
  region = "us-central1"
}

resource "google_compute_disk" "disk" {
  name  = "my-base-disk"
  image = "debian-cloud/debian-9"
  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"
}

resource "google_compute_region_disk" "ssd" {
  name  = "my-disk"
  replica_zones = ["us-central1-a", "us-central1-f"]
  snapshot = google_compute_snapshot.snapdisk.id
  size  = 50
  type  = "pd-ssd"
  region  = "us-central1"
}

resource "google_compute_resource_policy" "policy" {
  name = "my-resource-policy"
  region = "us-central1"
  snapshot_schedule_policy {
    schedule {
      daily_schedule {
        days_in_cycle = 1
        start_time = "04:00"
      }
    }
  }
}

data "google_compute_image" "my_image" {
  family  = "debian-9"
  project = "debian-cloud"
}

» Argument Reference

The following arguments are supported:

  • name - (Required) The resource policy to be attached to the disk for scheduling snapshot creation. Do not specify the self link.

  • disk - (Required) The name of the regional disk in which the resource policies are attached to.


  • region - (Optional) A reference to the region where the disk resides.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

» Attributes Reference

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

  • id - an identifier for the resource with format {{project}}/{{region}}/{{disk}}/{{name}}

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

RegionDiskResourcePolicyAttachment can be imported using any of these accepted formats:

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

» User Project Overrides

This resource supports User Project Overrides.