Skip to content

googleComputeDiskResourcePolicyAttachment

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

\~> Note: This resource does not support regional disks (googleComputeRegionDisk). For regional disks, please refer to googleComputeRegionDiskResourcePolicyAttachment

Example Usage - Disk Resource Policy Attachment Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeResourcePolicyPolicy =
  new google.computeResourcePolicy.ComputeResourcePolicy(this, "policy", {
    name: "my-resource-policy",
    region: "us-central1",
    snapshot_schedule_policy: [
      {
        schedule: [
          {
            daily_schedule: [
              {
                days_in_cycle: 1,
                start_time: "04:00",
              },
            ],
          },
        ],
      },
    ],
  });
const dataGoogleComputeImageMyImage =
  new google.dataGoogleComputeImage.DataGoogleComputeImage(this, "my_image", {
    family: "debian-11",
    project: "debian-cloud",
  });
const googleComputeDiskSsd = new google.computeDisk.ComputeDisk(this, "ssd", {
  image: dataGoogleComputeImageMyImage.selfLink,
  name: "my-disk",
  size: 50,
  type: "pd-ssd",
  zone: "us-central1-a",
});
new google.computeDiskResourcePolicyAttachment.ComputeDiskResourcePolicyAttachment(
  this,
  "attachment",
  {
    disk: googleComputeDiskSsd.name,
    name: googleComputeResourcePolicyPolicy.name,
    zone: "us-central1-a",
  }
);

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.

Attributes Reference

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

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

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • delete - Default is 20 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.