Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.
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-11"
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-11"
project = "debian-cloud"
}
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.
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}}
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.delete
- Default is 20 minutes.RegionDiskResourcePolicyAttachment can be imported using any of these accepted formats:
projects/{{project}}/regions/{{region}}/disks/{{disk}}/{{name}}
{{project}}/{{region}}/{{disk}}/{{name}}
{{region}}/{{disk}}/{{name}}
{{disk}}/{{name}}
In Terraform v1.5.0 and later, use an import
block to import RegionDiskResourcePolicyAttachment using one of the formats above. For example:
import {
id = "projects/{{project}}/regions/{{region}}/disks/{{disk}}/{{name}}"
to = google_compute_region_disk_resource_policy_attachment.default
}
When using the terraform import
command, RegionDiskResourcePolicyAttachment can be imported using one of the formats above. For example:
$ 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}}
This resource supports User Project Overrides.