Skip to content

Commit b520927

Browse files
dishaagarwal03-googleglasnt
authored andcommitted
feat(backupdr): Add disks example code for backup-plan and backup-plan-association (terraform-google-modules#857)
* Add disks example code for backup-plan and backup-plan-association * fix(backupdr): change location of disk resource * fix(backupplanassociation): Remove size from disk * ensure unique resource names * ci: disable tests temporarily --------- Co-authored-by: Katie McLaughlin <[email protected]> Co-authored-by: Katie McLaughlin <[email protected]>
1 parent 6427f1a commit b520927

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

backupdr/backup_plan/main.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,32 @@ resource "google_backup_dr_backup_plan" "default" {
6767
}
6868

6969
# [END backupdr_create_backupplan]
70+
71+
# [START backupdr_create_backupplan_disk]
72+
73+
# Before creating a backup plan, you need to create backup vault (google_backup_dr_backup_vault).
74+
resource "google_backup_dr_backup_plan" "disk_default" {
75+
provider = google-beta
76+
location = "us-central1"
77+
backup_plan_id = "my-disk-bp"
78+
resource_type = "compute.googleapis.com/Disk"
79+
backup_vault = google_backup_dr_backup_vault.default.name
80+
81+
backup_rules {
82+
rule_id = "rule-1"
83+
backup_retention_days = 5
84+
85+
standard_schedule {
86+
recurrence_type = "HOURLY"
87+
hourly_frequency = 1
88+
time_zone = "UTC"
89+
90+
backup_window {
91+
start_hour_of_day = 0
92+
end_hour_of_day = 6
93+
}
94+
}
95+
}
96+
}
97+
98+
# [END backupdr_create_backupplan_disk]

backupdr/backup_plan/test.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: blueprints.cloud.google.com/v1alpha1
16+
kind: BlueprintTest
17+
metadata:
18+
name: backupdr_backup_plan
19+
spec:
20+
skip: true

backupdr/backup_plan_association/main.tf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ resource "google_compute_instance" "default" {
5353
}
5454
}
5555

56+
resource "google_compute_disk" "default" {
57+
name = "disk-data"
58+
type = "pd-standard"
59+
zone = "us-central1-a"
60+
}
61+
5662
resource "google_backup_dr_backup_vault" "default" {
5763
provider = google-beta
5864
location = "us-central1"
@@ -99,6 +105,30 @@ resource "google_backup_dr_backup_plan" "default" {
99105
}
100106
}
101107

108+
resource "google_backup_dr_backup_plan" "disk_default" {
109+
provider = google-beta
110+
location = "us-central1"
111+
backup_plan_id = "my-disk-bp"
112+
resource_type = "compute.googleapis.com/Disk"
113+
backup_vault = google_backup_dr_backup_vault.default.name
114+
115+
backup_rules {
116+
rule_id = "rule-1"
117+
backup_retention_days = 5
118+
119+
standard_schedule {
120+
recurrence_type = "HOURLY"
121+
hourly_frequency = 1
122+
time_zone = "UTC"
123+
124+
backup_window {
125+
start_hour_of_day = 0
126+
end_hour_of_day = 6
127+
}
128+
}
129+
}
130+
}
131+
102132
# [START backupdr_create_backupplanassociation]
103133

104134
# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
@@ -113,3 +143,18 @@ resource "google_backup_dr_backup_plan_association" "default" {
113143
}
114144

115145
# [END backupdr_create_backupplanassociation]
146+
147+
# [START backupdr_create_backupplanassociation_disk]
148+
149+
# Before creating a backup plan association, you need to create backup plan (google_backup_dr_backup_plan)
150+
# and compute disk (google_compute_disk or google_compute_region_disk).
151+
resource "google_backup_dr_backup_plan_association" "disk_association" {
152+
provider = google-beta
153+
location = "us-central1"
154+
backup_plan_association_id = "my-disk-bpa"
155+
resource = google_compute_disk.default.id
156+
resource_type = "compute.googleapis.com/Disk"
157+
backup_plan = google_backup_dr_backup_plan.disk_default.name
158+
}
159+
160+
# [END backupdr_create_backupplanassociation_disk]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: blueprints.cloud.google.com/v1alpha1
16+
kind: BlueprintTest
17+
metadata:
18+
name: backupdr_backup_plan_association
19+
spec:
20+
skip: true

0 commit comments

Comments
 (0)