google_compute_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.

Open in Cloud Shell

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-11"
  project = "debian-cloud"
}

Argument Reference

The following arguments are supported:


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

DiskResourcePolicyAttachment can be imported using any of these accepted formats:

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

import {
  id = "projects/{{project}}/zones/{{zone}}/disks/{{disk}}/{{name}}"
  to = google_compute_disk_resource_policy_attachment.default
}

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

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