Skip to content

Commit 8cf79bf

Browse files
Documentation changes to include "disk" resource type in backup_dr (#13922) (#10159)
[upstream:e29e37ce2360cae0b7cdc0cca3c0863ead6265f5] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent c63b40c commit 8cf79bf

File tree

5 files changed

+116
-11
lines changed

5 files changed

+116
-11
lines changed

google-beta/services/backupdr/resource_backup_dr_backup_plan.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,11 @@ This is required for 'recurrence_type', 'HOURLY' and is not applicable otherwise
206206
Description: `The location for the backup plan`,
207207
},
208208
"resource_type": {
209-
Type: schema.TypeString,
210-
Required: true,
211-
ForceNew: true,
212-
Description: `The resource type to which the 'BackupPlan' will be applied. Examples include, "compute.googleapis.com/Instance" and "storage.googleapis.com/Bucket".`,
209+
Type: schema.TypeString,
210+
Required: true,
211+
ForceNew: true,
212+
Description: `The resource type to which the 'BackupPlan' will be applied.
213+
Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Disk", and "storage.googleapis.com/Bucket".`,
213214
},
214215
"description": {
215216
Type: schema.TypeString,

google-beta/services/backupdr/resource_backup_dr_backup_plan_association.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ func ResourceBackupDRBackupPlanAssociation() *schema.Resource {
5858
Required: true,
5959
ForceNew: true,
6060
DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress,
61-
Description: `The BP with which resource needs to be created`,
61+
Description: `The BP with which resource needs to be created
62+
Note:
63+
- A Backup Plan configured for 'compute.googleapis.com/Instance', can only protect instance type resources.
64+
- A Backup Plan configured for 'compute.googleapis.com/Disk' can be used to protect both standard Disks and Regional Disks resources.`,
6265
},
6366
"backup_plan_association_id": {
6467
Type: schema.TypeString,
@@ -79,10 +82,11 @@ func ResourceBackupDRBackupPlanAssociation() *schema.Resource {
7982
Description: `The resource for which BPA needs to be created`,
8083
},
8184
"resource_type": {
82-
Type: schema.TypeString,
83-
Required: true,
84-
ForceNew: true,
85-
Description: `The resource type of workload on which backupplan is applied`,
85+
Type: schema.TypeString,
86+
Required: true,
87+
ForceNew: true,
88+
Description: `The resource type of workload on which backupplan is applied.
89+
Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Disk", and "compute.googleapis.com/RegionDisk"`,
8690
},
8791
"create_time": {
8892
Type: schema.TypeString,

google-beta/services/backupdr/resource_backup_dr_backup_plan_generated_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,66 @@ resource "google_backup_dr_backup_plan" "my-backup-plan-1" {
8888
`, context)
8989
}
9090

91+
func TestAccBackupDRBackupPlan_backupDrBackupPlanForDiskResourceExample(t *testing.T) {
92+
t.Parallel()
93+
94+
context := map[string]interface{}{
95+
"random_suffix": acctest.RandString(t, 10),
96+
}
97+
98+
acctest.VcrTest(t, resource.TestCase{
99+
PreCheck: func() { acctest.AccTestPreCheck(t) },
100+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
101+
CheckDestroy: testAccCheckBackupDRBackupPlanDestroyProducer(t),
102+
Steps: []resource.TestStep{
103+
{
104+
Config: testAccBackupDRBackupPlan_backupDrBackupPlanForDiskResourceExample(context),
105+
},
106+
{
107+
ResourceName: "google_backup_dr_backup_plan.my-disk-backup-plan-1",
108+
ImportState: true,
109+
ImportStateVerify: true,
110+
ImportStateVerifyIgnore: []string{"backup_plan_id", "location"},
111+
},
112+
},
113+
})
114+
}
115+
116+
func testAccBackupDRBackupPlan_backupDrBackupPlanForDiskResourceExample(context map[string]interface{}) string {
117+
return acctest.Nprintf(`
118+
resource "google_backup_dr_backup_vault" "my_backup_vault" {
119+
provider = google-beta
120+
location = "us-central1"
121+
backup_vault_id = "tf-test-backup-vault-disk-test%{random_suffix}"
122+
backup_minimum_enforced_retention_duration = "100000s"
123+
}
124+
125+
resource "google_backup_dr_backup_plan" "my-disk-backup-plan-1" {
126+
provider = google-beta
127+
location = "us-central1"
128+
backup_plan_id = "tf-test-backup-plan-disk-test%{random_suffix}"
129+
resource_type = "compute.googleapis.com/Disk"
130+
backup_vault = google_backup_dr_backup_vault.my_backup_vault.id
131+
132+
backup_rules {
133+
rule_id = "rule-1"
134+
backup_retention_days = 5
135+
136+
standard_schedule {
137+
recurrence_type = "HOURLY"
138+
hourly_frequency = 1
139+
time_zone = "UTC"
140+
141+
backup_window {
142+
start_hour_of_day = 0
143+
end_hour_of_day = 6
144+
}
145+
}
146+
}
147+
}
148+
`, context)
149+
}
150+
91151
func testAccCheckBackupDRBackupPlanDestroyProducer(t *testing.T) func(s *terraform.State) error {
92152
return func(s *terraform.State) error {
93153
for name, rs := range s.RootModule().Resources {

website/docs/r/backup_dr_backup_plan.html.markdown

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,41 @@ resource "google_backup_dr_backup_plan" "my-backup-plan-1" {
6363
}
6464
}
6565
```
66+
## Example Usage - Backup Dr Backup Plan For Disk Resource
67+
68+
69+
```hcl
70+
resource "google_backup_dr_backup_vault" "my_backup_vault" {
71+
provider = google-beta
72+
location = "us-central1"
73+
backup_vault_id = "backup-vault-disk-test"
74+
backup_minimum_enforced_retention_duration = "100000s"
75+
}
76+
77+
resource "google_backup_dr_backup_plan" "my-disk-backup-plan-1" {
78+
provider = google-beta
79+
location = "us-central1"
80+
backup_plan_id = "backup-plan-disk-test"
81+
resource_type = "compute.googleapis.com/Disk"
82+
backup_vault = google_backup_dr_backup_vault.my_backup_vault.id
83+
84+
backup_rules {
85+
rule_id = "rule-1"
86+
backup_retention_days = 5
87+
88+
standard_schedule {
89+
recurrence_type = "HOURLY"
90+
hourly_frequency = 1
91+
time_zone = "UTC"
92+
93+
backup_window {
94+
start_hour_of_day = 0
95+
end_hour_of_day = 6
96+
}
97+
}
98+
}
99+
}
100+
```
66101

67102
## Argument Reference
68103

@@ -75,7 +110,8 @@ The following arguments are supported:
75110

76111
* `resource_type` -
77112
(Required)
78-
The resource type to which the `BackupPlan` will be applied. Examples include, "compute.googleapis.com/Instance" and "storage.googleapis.com/Bucket".
113+
The resource type to which the `BackupPlan` will be applied.
114+
Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Disk", and "storage.googleapis.com/Bucket".
79115

80116
* `backup_rules` -
81117
(Required)

website/docs/r/backup_dr_backup_plan_association.html.markdown

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,14 @@ The following arguments are supported:
117117
* `backup_plan` -
118118
(Required)
119119
The BP with which resource needs to be created
120+
Note:
121+
- A Backup Plan configured for 'compute.googleapis.com/Instance', can only protect instance type resources.
122+
- A Backup Plan configured for 'compute.googleapis.com/Disk' can be used to protect both standard Disks and Regional Disks resources.
120123

121124
* `resource_type` -
122125
(Required)
123-
The resource type of workload on which backupplan is applied
126+
The resource type of workload on which backupplan is applied.
127+
Examples include, "compute.googleapis.com/Instance", "compute.googleapis.com/Disk", and "compute.googleapis.com/RegionDisk"
124128

125129
* `location` -
126130
(Required)

0 commit comments

Comments
 (0)