» google_compute_disk_resource_policy_attachment

Disk resource policies define a schedule for taking snapshots and a retention period for these snapshots.

» Example Usage - Disk Resource Policy Attachment Basic

resource "google_compute_disk_resource_policy_attachment" "attachment" {
  name = google_compute_resource_policy.policy.name
  disk = google_compute_disk.ssd.name
  zone = "us-central1-a"
}

resource "google_compute_disk" "ssd" {
  name  = "my-disk"
  image = data.google_compute_image.my_image.self_link
  size  = 50
  type  = "pd-ssd"
  zone  = "us-central1-a"
}

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 disk in which the resource policies are attached to.


  • zone - (Optional) A reference to the zone 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.

» Timeouts

This resource provides the following Timeouts configuration options:

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

» Import

DiskResourcePolicyAttachment can be imported using any of these accepted formats:

$ terraform import google_compute_disk_resource_policy_attachment.default projects/{{project}}/zones/{{zone}}/disks/{{disk}}/{{name}}
$ terraform import google_compute_disk_resource_policy_attachment.default {{project}}/{{zone}}/{{disk}}/{{name}}
$ terraform import google_compute_disk_resource_policy_attachment.default {{zone}}/{{disk}}/{{name}}
$ terraform import google_compute_disk_resource_policy_attachment.default {{disk}}/{{name}}

» User Project Overrides

This resource supports User Project Overrides.