Skip to content

googleComputeRegionDiskResourcePolicyAttachment

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 zonal disks (googleComputeDisk). For zonal disks, please refer to googleComputeDiskResourcePolicyAttachment

Example Usage - Region 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 googleComputeDiskDisk = new google.computeDisk.ComputeDisk(this, "disk", {
  image: "debian-cloud/debian-11",
  name: "my-base-disk",
  size: 50,
  type: "pd-ssd",
  zone: "us-central1-a",
});
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 googleComputeSnapshotSnapdisk =
  new google.computeSnapshot.ComputeSnapshot(this, "snapdisk", {
    name: "my-snapshot",
    source_disk: googleComputeDiskDisk.name,
    zone: "us-central1-a",
  });
new google.dataGoogleComputeImage.DataGoogleComputeImage(this, "my_image", {
  family: "debian-11",
  project: "debian-cloud",
});
const googleComputeRegionDiskSsd =
  new google.computeRegionDisk.ComputeRegionDisk(this, "ssd", {
    name: "my-disk",
    region: "us-central1",
    replica_zones: ["us-central1-a", "us-central1-f"],
    size: 50,
    snapshot: googleComputeSnapshotSnapdisk.id,
    type: "pd-ssd",
  });
new google.computeRegionDiskResourcePolicyAttachment.ComputeRegionDiskResourcePolicyAttachment(
  this,
  "attachment",
  {
    disk: googleComputeRegionDiskSsd.name,
    name: googleComputeResourcePolicyPolicy.name,
    region: "us-central1",
  }
);

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